realpath to get filepath breaks external filesystem

Created on 14 February 2024, 11 months ago

Problem/Motivation

I use S3 filesystem (s3://...) and the asset/media folder is empty or an error occurred

I found the same issue/resolution in webform module : https://www.drupal.org/project/webform/issues/3084045

Steps to reproduce

With https://www.drupal.org/project/s3fs installed & configured

drush content:synchronizer-export-entity node 1885
result :
an error occurred :
Error: Path cannot be empty in /app/public/web/modules/contrib/content_synchronizer/src/Service/ContentSynchronizerManager.php on line 353 #0 /app/public/web/modules/contrib/content_synchronizer/src/Service/ContentSynchronizerManager.php(353): copy()...

Proposed resolution

in src/Plugin/content_synchronizer/entity_processor/FileProcessor.php line 127

$this->fileSystem->copy($this->fileSystem->realpath($file->getFileUri()), $destination);

replace by :

    // File URIs that are not supportted return FALSE, when this happens
    // still use the file's URI as the file's path. 
    $source = $this->fileSystem->realpath($file->getFileUri()) ?: $file->getFileUri();

    // Copy file in destination directory.
    $this->fileSystem->copy($source, $destination);
🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇫🇷France pierrelbz Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024