[+BUGFIX] Extbase (Persistence): Persistence_Backend::getIdentifierByObject should...
authorSebastian Kurfürst <sebastian@typo3.org>
Wed, 1 Dec 2010 07:08:57 +0000 (07:08 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Wed, 1 Dec 2010 07:08:57 +0000 (07:08 +0000)
getIdentifierByObject should check if object is an instance of Tx_Extbase_Persistence_LazyLoadingProxy and should return the
identifier of the real object.

Resolves: #11194

typo3/sysext/extbase/Classes/Persistence/Backend.php

index 34222e3..32e4d84 100644 (file)
@@ -246,6 +246,12 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
         * @return string The identifier for the object if it is known, or NULL
         */
        public function getIdentifierByObject($object) {
+               if ($object instanceof Tx_Extbase_Persistence_LazyLoadingProxy) {
+                       $object = $object->_loadRealInstance();
+                       if (!is_object($object)) {
+                               return NULL;
+                       }
+               }
                if ($this->identityMap->hasObject($object)) {
                        return $this->identityMap->getIdentifierByObject($object);
                } else {