[!!!][TASK] Remove IdentityMap from persistence 01/38701/6
authorMathias Brodala <mbrodala@pagemachine.de>
Wed, 15 Apr 2015 09:29:59 +0000 (11:29 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Thu, 7 May 2015 06:57:30 +0000 (08:57 +0200)
The IdentityMap class has been deprecated since 6.1 and is removed
from the Extbase persistence.

Resolves: #66429
Releases: master
Change-Id: I150b86190bbe7d0c9431d5495c8460241681f439
Reviewed-on: http://review.typo3.org/38701
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/compatibility6/Migrations/Code/ClassAliasMap.php
typo3/sysext/compatibility6/Migrations/Code/LegacyClassesForIde.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-66429-RemoveIdentityMapFromPersistence.rst [new file with mode: 0644]
typo3/sysext/extbase/Classes/Persistence/Generic/IdentityMap.php [deleted file]
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php
typo3/sysext/extbase/Classes/Persistence/Repository.php
typo3/sysext/extbase/Classes/Utility/DebuggerUtility.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapperTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/RepositoryTest.php

index 9f5bf7e..2e484bf 100644 (file)
@@ -419,7 +419,6 @@ return array(
        'Tx_Extbase_Persistence_Exception_UnsupportedOrder' => \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedOrderException::class,
        'Tx_Extbase_Persistence_Exception_UnsupportedRelation' => \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedRelationException::class,
        'Tx_Extbase_Persistence_Generic_Exception_InconsistentQuerySettings' => \TYPO3\CMS\Extbase\Persistence\Generic\Exception\InconsistentQuerySettingsException::class,
-       'Tx_Extbase_Persistence_IdentityMap' => \TYPO3\CMS\Extbase\Persistence\Generic\IdentityMap::class,
        'Tx_Extbase_Persistence_LazyLoadingProxy' => \TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy::class,
        'Tx_Extbase_Persistence_LazyObjectStorage' => \TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage::class,
        'Tx_Extbase_Persistence_LoadingStrategyInterface' => \TYPO3\CMS\Extbase\Persistence\Generic\LoadingStrategyInterface::class,
index f645904..ea33f41 100644 (file)
@@ -2109,11 +2109,6 @@ class Tx_Extbase_Persistence_Generic_Exception_InconsistentQuerySettings extends
 /**
  * @deprecated since 6.0, removed since 7.0
  */
-class Tx_Extbase_Persistence_IdentityMap extends \TYPO3\CMS\Extbase\Persistence\Generic\IdentityMap {}
-
-/**
- * @deprecated since 6.0, removed since 7.0
- */
 class Tx_Extbase_Persistence_LazyLoadingProxy extends \TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy {}
 
 /**
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-66429-RemoveIdentityMapFromPersistence.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-66429-RemoveIdentityMapFromPersistence.rst
new file mode 100644 (file)
index 0000000..f02b37c
--- /dev/null
@@ -0,0 +1,41 @@
+======================================================
+Breaking - #66429: Remove IdentityMap from persistence
+======================================================
+
+Description
+===========
+
+The ``IdentityMap`` class and its usage has been removed from the Extbase persistence.
+
+
+Impact
+======
+
+Upgraded installations will throw a ``ReflectionException``. Accessing the previously existing ``IdentityMap`` properties within ``DataMapper`` and ``Repository`` will now fail. Creating ``IdentityMap`` instances is not possible anymore.
+
+
+Affected Installations
+======================
+
+All installations, especially extensions using the ``IdentityMap`` class directly or accessing the properties within ``DataMapper`` or ``Repository``.
+
+
+Migration
+=========
+
+The Extbase reflection cache of existing installations needs to be cleared once.
+
+Existing code can be migrated to the persistence ``Session`` class which provides a drop-in replacement for the ``IdentityMap``.
+
+Usage example
+=============
+
+How to use the ``Session`` class to retrieve objects by an identifier:
+
+.. code-block:: php
+
+       $session = GeneralUtility::makeInstance(ObjectManager::class)->get(\TYPO3\CMS\Extbase\Persistence\Generic\Session::class);
+       $session->registerObject($object, $identifier);
+       if ($session->hasIdentifier($identifier)) {
+               $object = $session->getObjectByIdentifier($identifier, $className);
+       }
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/IdentityMap.php b/typo3/sysext/extbase/Classes/Persistence/Generic/IdentityMap.php
deleted file mode 100644 (file)
index f69ee9b..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-namespace TYPO3\CMS\Extbase\Persistence\Generic;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-/**
- * An identity mapper to map nodes to objects
- *
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- * @see \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper
- * @see \TYPO3\CMS\Extbase\Persistence\Generic\Backend
- * @deprecated since 6.1, will be removed two versions later, use the persistence session instead
- */
-class IdentityMap implements \TYPO3\CMS\Core\SingletonInterface {
-
-       /**
-        * @var \TYPO3\CMS\Extbase\Persistence\Generic\Session
-        * @inject
-        */
-       protected $persistenceSession;
-
-       /**
-        * Checks whether the given object is known to the identity map
-        *
-        * @param object $object
-        * @return bool
-        * @deprecated since 6.1, will be removed two versions later, use the persistence session instead
-        */
-       public function hasObject($object) {
-               return $this->persistenceSession->hasObject($object);
-       }
-
-       /**
-        * Checks whether the given UUID is known to the identity map
-        *
-        * @param string $uuid
-        * @param string $className
-        * @return bool
-        * @deprecated since 6.1, will be removed two versions later, use the persistence session instead
-        */
-       public function hasIdentifier($uuid, $className) {
-               return $this->persistenceSession->hasIdentifier($uuid, $className);
-       }
-
-       /**
-        * Returns the object for the given UUID
-        *
-        * @param string $uuid
-        * @param string $className
-        * @return object
-        * @deprecated since 6.1, will be removed two versions later, use the persistence session instead
-        */
-       public function getObjectByIdentifier($uuid, $className) {
-               return $this->persistenceSession->getObjectByIdentifier($uuid, $className);
-       }
-
-       /**
-        * Returns the node identifier for the given object
-        *
-        * @param object $object
-        * @throws \InvalidArgumentException
-        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
-        * @return string
-        * @deprecated since 6.1, will be removed two versions later, use the persistence session instead
-        */
-       public function getIdentifierByObject($object) {
-               return $this->persistenceSession->getIdentifierByObject($object);
-       }
-
-       /**
-        * Register a node identifier for an object
-        *
-        * @param object $object
-        * @param string $uuid
-        * @deprecated since 6.1, will be removed two versions later, use the persistence session instead
-        */
-       public function registerObject($object, $uuid) {
-               $this->persistenceSession->registerObject($object, $uuid);
-       }
-
-       /**
-        * Unregister an object
-        *
-        * @param object $object
-        * @return void
-        * @deprecated since 6.1, will be removed two versions later, use the persistence session instead
-        */
-       public function unregisterObject($object) {
-               $this->persistenceSession->unregisterObject($object);
-       }
-
-}
index 753ac85..6dc88bc 100644 (file)
@@ -26,12 +26,6 @@ use TYPO3\CMS\Extbase\Utility\TypeHandlingUtility;
 class DataMapper implements \TYPO3\CMS\Core\SingletonInterface {
 
        /**
-        * @var \TYPO3\CMS\Extbase\Persistence\Generic\IdentityMap
-        * @inject
-        */
-       protected $identityMap;
-
-       /**
         * @var \TYPO3\CMS\Extbase\Reflection\ReflectionService
         * @inject
         */
@@ -133,13 +127,13 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface {
         * @return object An object of the given class
         */
        protected function mapSingleRow($className, array $row) {
-               if ($this->identityMap->hasIdentifier($row['uid'], $className)) {
-                       $object = $this->identityMap->getObjectByIdentifier($row['uid'], $className);
+               if ($this->persistenceSession->hasIdentifier($row['uid'], $className)) {
+                       $object = $this->persistenceSession->getObjectByIdentifier($row['uid'], $className);
                } else {
                        $object = $this->createEmptyObject($className);
-                       $this->identityMap->registerObject($object, $row['uid']);
                        $this->thawProperties($object, $row);
                        $object->_memorizeCleanState();
+                       $this->persistenceSession->registerObject($object, $row['uid']);
                        $this->persistenceSession->registerReconstitutedEntity($object);
                }
                return $object;
@@ -418,7 +412,7 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface {
         * mapResultToPropertyValue()
         *
         * If the field value is empty and the column map has no parent key field name,
-        * the relation will be empty. If the identityMap has a registered object of
+        * the relation will be empty. If the persistence session has a registered object of
         * the correct type and identity (fieldValue), this function returns that object.
         * Otherwise, it proceeds with mapResultToPropertyValue().
         *
index d723184..5ff4956 100644 (file)
@@ -24,13 +24,6 @@ use TYPO3\CMS\Core\Utility\ClassNamingUtility;
 class Repository implements RepositoryInterface, \TYPO3\CMS\Core\SingletonInterface {
 
        /**
-        * @var \TYPO3\CMS\Extbase\Persistence\Generic\IdentityMap
-        * @deprecated since 6.1 will be removed two versions later, use the persistence session instead
-        * @inject
-        */
-       protected $identityMap;
-
-       /**
         * @var \TYPO3\CMS\Extbase\Persistence\Generic\Session
         * @deprecated since 6.1 will be removed two versions later, use the persistence manager instead
         * @inject
index d3cb262..ff1fdf9 100644 (file)
@@ -47,7 +47,6 @@ class DebuggerUtility {
         */
        static protected $blacklistedClassNames = array(
                'PHPUnit_Framework_MockObject_InvocationMocker',
-               \TYPO3\CMS\Extbase\Persistence\Generic\IdentityMap::class,
                \TYPO3\CMS\Extbase\Reflection\ReflectionService::class,
                \TYPO3\CMS\Extbase\Object\ObjectManager::class,
                \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::class,
index 48151d3..2b58db5 100644 (file)
@@ -41,14 +41,14 @@ class DataMapperTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @test
         */
-       public function mapSingleRowReturnsObjectFromIdentityMapIfAvailable() {
+       public function mapSingleRowReturnsObjectFromPersistenceSessionIfAvailable() {
                $row = array('uid' => '1234');
                $object = new \stdClass();
-               $identityMap = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\IdentityMap::class);
-               $identityMap->expects($this->once())->method('hasIdentifier')->with('1234')->will($this->returnValue(TRUE));
-               $identityMap->expects($this->once())->method('getObjectByIdentifier')->with('1234')->will($this->returnValue($object));
+               $persistenceSession = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\Session::class);
+               $persistenceSession->expects($this->once())->method('hasIdentifier')->with('1234')->will($this->returnValue(TRUE));
+               $persistenceSession->expects($this->once())->method('getObjectByIdentifier')->with('1234')->will($this->returnValue($object));
                $dataMapper = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::class, array('dummy'));
-               $dataMapper->_set('identityMap', $identityMap);
+               $dataMapper->_set('persistenceSession', $persistenceSession);
                $dataMapper->_call('mapSingleRow', get_class($object), $row);
        }
 
@@ -309,4 +309,4 @@ class DataMapperTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertSame(23, $dataMapper->getPlainValue($input));
        }
 
-}
\ No newline at end of file
+}
index 0a41ae4..43abd8d 100644 (file)
@@ -30,11 +30,6 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        protected $mockObjectManager;
 
        /**
-        * @var \TYPO3\CMS\Extbase\Persistence\Generic\IdentityMap
-        */
-       protected $mockIdentityMap;
-
-       /**
         * @var \TYPO3\CMS\Extbase\Persistence\Generic\QueryFactory
         */
        protected $mockQueryFactory;
@@ -70,7 +65,6 @@ class RepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        protected $mockConfigurationManager;
 
        protected function setUp() {
-               $this->mockIdentityMap = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\IdentityMap::class);
                $this->mockQueryFactory = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\QueryFactory::class);
                $this->mockQuery = $this->getMock(\TYPO3\CMS\Extbase\Persistence\QueryInterface::class);
                $this->mockQuerySettings = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface::class);