[BUGFIX] Fatal error when copying file or folder
authorAndreas Wolf <andreas.wolf@typo3.org>
Wed, 3 Oct 2012 14:38:22 +0000 (16:38 +0200)
committerSteffen Ritter <info@rs-websystems.de>
Wed, 10 Oct 2012 14:40:56 +0000 (16:40 +0200)
When copying a file or folder, a fatal error is thrown if anything went
wrong. This happens because the error message was written to the log,
but the ExtendedFileUtility class also tried to output a (wrong) success
message containing the (not existing) target object.

Change-Id: If825e241ad60b7a2a65bd0826133005a3ba91091
Resolves: #41292
Releases: 6.0
Reviewed-on: http://review.typo3.org/15258
Reviewed-by: Benjamin Mack
Tested-by: Benjamin Mack
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php

index fdafa09..1d12ad8 100644 (file)
@@ -494,7 +494,9 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
                        } catch (\RuntimeException $e) {
                                $this->writelog(2, 2, 109, 'File "%s" WAS NOT copied to "%s"! Write-permission problem?', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
                        }
-                       $this->writelog(2, 0, 1, 'File "%s" copied to "%s"', array($sourceFileObject->getIdentifier(), $resultObject->getIdentifier()));
+                       if ($resultObject) {
+                               $this->writelog(2, 0, 1, 'File "%s" copied to "%s"', array($sourceFileObject->getIdentifier(), $resultObject->getIdentifier()));
+                       }
                } else {
                        // Else means this is a Folder
                        $sourceFolderObject = $sourceFileObject;
@@ -514,7 +516,9 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
                        } catch (\RuntimeException $e) {
                                $this->writelog(2, 2, 119, 'Directory "%s" WAS NOT copied to "%s"! Write-permission problem?', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
                        }
-                       $this->writelog(2, 0, 2, 'Directory "%s" copied to "%s"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
+                       if ($resultObject) {
+                               $this->writelog(2, 0, 2, 'Directory "%s" copied to "%s"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
+                       }
                }
                return $resultObject;
        }
@@ -909,4 +913,4 @@ class ExtendedFileUtility extends \TYPO3\CMS\Core\Utility\File\BasicFileUtility
 }
 
 
-?>
\ No newline at end of file
+?>