[BUGFIX] Segfaults on object comparisons 16/19316/3
authorAndreas Wolf <andreas.wolf@typo3.org>
Sat, 23 Mar 2013 10:12:38 +0000 (11:12 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 26 Mar 2013 20:17:47 +0000 (21:17 +0100)
In the ResourceStorage class, the identity of source and target storage
has to be verified for several operations (copy, move). When the
comparison is done with a simple equality operator (==), the properties
of both objects are compared when the objects are not identical. This
comparison led to a segfault in several environments, presumably because
of a meanwhile fixed PHP bug (https://bugs.php.net/bug.php?id=61557).

To prevent these segfaults on affected PHP versions, the comparison is
extended to check for object identity (===). This will not affect the
behaviour of the code, as there should always be only one object per
storage.

Change-Id: I378c447f75c00859447cf1443f64b81e54161c54
Resolves: #46584
Releases: 6.1, 6.0
Reviewed-on: https://review.typo3.org/19316
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Classes/Resource/ResourceStorage.php

index 952a74d..2c8c454 100644 (file)
@@ -1032,7 +1032,7 @@ class ResourceStorage {
                // Call driver method to create a new file from an existing file object,
                // and return the new file object
                try {
-                       if ($sourceStorage == $this) {
+                       if ($sourceStorage === $this) {
                                $newFileObject = $this->driver->copyFileWithinStorage($file, $targetFolder, $targetFileName);
                        } else {
                                $tempPath = $file->getForLocalProcessing();
@@ -1155,7 +1155,7 @@ class ResourceStorage {
                // Call driver method to move the file that also updates the file
                // object properties
                try {
-                       if ($sourceStorage == $this) {
+                       if ($sourceStorage === $this) {
                                $newIdentifier = $this->driver->moveFileWithinStorage($file, $targetFolder, $targetFileName);
                                $this->updateFile($file, $newIdentifier);
                        } else {
@@ -1377,7 +1377,7 @@ class ResourceStorage {
                // Get all file objects now so we are able to update them after moving the folder
                $fileObjects = $this->getAllFileObjectsInFolder($folderToMove);
                try {
-                       if ($sourceStorage == $this) {
+                       if ($sourceStorage === $this) {
                                $fileMappings = $this->driver->moveFolderWithinStorage($folderToMove, $targetParentFolder, $newFolderName);
                        } else {
                                $fileMappings = $this->moveFolderBetweenStorages($folderToMove, $targetParentFolder, $newFolderName);
@@ -1428,7 +1428,7 @@ class ResourceStorage {
                // call driver method to move the file
                // that also updates the file object properties
                try {
-                       if ($sourceStorage == $this) {
+                       if ($sourceStorage === $this) {
                                $this->driver->copyFolderWithinStorage($folderToCopy, $targetParentFolder, $newFolderName);
                                $returnObject = $this->getFolder($targetParentFolder->getSubfolder($newFolderName)->getIdentifier());
                        } else {