[BUGFIX] DataMapFactory::resolveTableName must remove leading backslashes 96/24596/4
authorAlexander Schnitzler <alex.schnitzler@typovision.de>
Fri, 11 Oct 2013 16:33:10 +0000 (18:33 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 11 Oct 2013 19:14:51 +0000 (21:14 +0200)
Currently the method just splits the given class name
by backslashes to detect the proper vendor name. If using
a leading backslash the algorithm of this function causes
a wrong result. Therefore all leading backslashes must be
removed first.

Releases: 6.2, 6.1, 6.0
Fixes: #52708
Change-Id: Icdc46facf66260bf528994964fb713d3dd24b3c6
Reviewed-on: https://review.typo3.org/24596
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
Reviewed-by: Stefan Froemken
Tested-by: Stefan Froemken
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapFactoryTest.php

index a6569fe..92ed44a 100644 (file)
@@ -160,6 +160,7 @@ class DataMapFactory implements \TYPO3\CMS\Core\SingletonInterface {
         * @return string The table name
         */
        protected function resolveTableName($className) {
+               $className = ltrim($className, '\\');
                if (strpos($className, '\\') !== FALSE) {
                        $classNameParts = explode('\\', $className, 6);
                        // Skip vendor and product name for core classes
index d9a808a..d3c4332 100644 (file)
@@ -413,8 +413,11 @@ class DataMapFactoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
        public function classNameTableNameMappings() {
                return array(
                        'Core classes' => array('TYPO3\\CMS\\Belog\\Domain\\Model\\LogEntry', 'tx_belog_domain_model_logentry'),
+                       'Core classes with namespaces and leading backslash' => array('\\TYPO3\\CMS\\Belog\\Domain\\Model\\LogEntry', 'tx_belog_domain_model_logentry'),
                        'Extension classes' => array('ExtbaseTeam\\BlogExample\\Domain\\Model\\Blog', 'tx_blogexample_domain_model_blog'),
+                       'Extension classes with namespaces and leading backslash' => array('\\ExtbaseTeam\\BlogExample\\Domain\\Model\\Blog', 'tx_blogexample_domain_model_blog'),
                        'Extension classes without namespace' => array('Tx_News_Domain_Model_News', 'tx_news_domain_model_news'),
+                       'Extension classes without namespace but leading slash' => array('\\Tx_News_Domain_Model_News', 'tx_news_domain_model_news'),
                );
        }