Issue #3463205: Catch FileNotExistsException and allow processing to continue
Open
requested to merge issue/file_access_fix-3463205:3463205-filenotexistsexception-prevents-user into 8.x-1.x
1 unresolved thread
Closes #3463205
Merge request reports
Activity
59 60 $targetDirectory = dirname($fileTargetUri); 60 61 $fileSystemService->prepareDirectory($targetDirectory, FileSystemInterface::CREATE_DIRECTORY); 61 62 // This will notify modules, e.f. for image derivations. 62 $movedFile = \Drupal::service('file.repository')->move($file, $fileTargetUri, FileSystemInterface::EXISTS_RENAME); 63 try { 64 $movedFile = \Drupal::service('file.repository')->move($file, $fileTargetUri, FileSystemInterface::EXISTS_RENAME); 65 } 66 catch (FileNotExistsException $e) { 67 \Drupal::logger('file_access_fix')->error('Exception thrown while moving file at @uri. @message', [ 68 '@uri' => $file->getFileUri(), 69 '@message' => $e->getMessage(), 70 ]); 71 continue; 72 } 63 73 if (!$movedFile) { I think catching the exception and logging it makes sense - I'm curious if that was always the intent of this code here - it looks like
FileRepository::move
either returns the file entity or throws an exception - I'm not sure if it ever evaluates to false for this logging code below to execute?Edited by Eric Smith
Please register or sign in to reply