[BUGFIX] Prevent strings from being autoloaded 79/27079/7
authorHelmut Hummel <helmut.hummel@typo3.org>
Mon, 27 Jan 2014 20:47:14 +0000 (21:47 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Wed, 29 Jan 2014 10:20:06 +0000 (11:20 +0100)
The introduction of a TypeConverter for Enumaration
types in #52762 added is_subclass() calls to
getPlainValue() in the DatabaseBackends. These methods
are meant to convert objects to simply types but are
regularly called with simple types, in particular strings.

Since is_subclass() also works with strings,
The class loader is triggered when these methods
are called with a table name like "tx_ext_domain_model_foo".

This triggers an issue #55418 in the class loader especially
on case insensitive filesystems.

Instead of is_subclass we now use instanceof to make sure
we only check for conversion if the value is an object.

Additionally this change fixes a wrong case statement which
also was introduced in #52762

Resolves: #54275
Change-Id: If1b2a28a2623e49dfb47720641935c6f24447c19
Reviewed-on: https://review.typo3.org/27079
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/extbase/Classes/Persistence/Generic/Backend.php
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php
typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php

index 591a27e..4610306 100644 (file)
@@ -27,7 +27,6 @@ namespace TYPO3\CMS\Extbase\Persistence\Generic;
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-use TYPO3\CMS\Extbase\Utility\TypeHandlingUtility;
 
 /**
  * A persistence backend. This backend maps objects to the relational model of the storage backend.
@@ -1009,7 +1008,7 @@ class Backend implements \TYPO3\CMS\Extbase\Persistence\Generic\BackendInterface
                        }
                } elseif ($input instanceof \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface) {
                        return $input->getUid();
-               } elseif (TypeHandlingUtility::isCoreType($input)) {
+               } elseif ($input instanceof \TYPO3\CMS\Core\Type\TypeInterface) {
                        return (string) $input;
                } elseif (is_bool($input)) {
                        return $input === TRUE ? 1 : 0;
index 6d1b178..72fc5fe 100644 (file)
@@ -222,12 +222,11 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface {
                                        case 'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage':
                                                $propertyValue = $this->mapResultToPropertyValue($object, $propertyName, $this->fetchRelated($object, $propertyName, $row[$columnName]));
                                                break;
-                                       case TypeHandlingUtility::isCoreType($propertyData['type']):
-                                               $propertyValue = $this->mapCoreType($propertyData['type'], $row[$columnName]);
-                                               break;
                                        default:
                                                if ($propertyData['type'] === 'DateTime' || in_array('DateTime', class_parents($propertyData['type']))) {
                                                        $propertyValue = $this->mapDateTime($row[$columnName], $columnMap->getDateTimeStorageFormat());
+                                               } elseif (TypeHandlingUtility::isCoreType($propertyData['type'])) {
+                                                       $propertyValue = $this->mapCoreType($propertyData['type'], $row[$columnName]);
                                                } else {
                                                        $propertyValue = $this->mapResultToPropertyValue($object, $propertyName, $this->fetchRelated($object, $propertyName, $row[$columnName]));
                                                }
index 460c5bf..18afc7a 100644 (file)
@@ -29,7 +29,6 @@ namespace TYPO3\CMS\Extbase\Persistence\Generic\Storage;
  ***************************************************************/
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
-use TYPO3\CMS\Extbase\Utility\TypeHandlingUtility;
 
 /**
  * A Storage backend
@@ -665,7 +664,7 @@ class Typo3DbBackend implements \TYPO3\CMS\Extbase\Persistence\Generic\Storage\B
                }
                if ($input instanceof \DateTime) {
                        return $input->format('U');
-               } elseif (TypeHandlingUtility::isCoreType($input)) {
+               } elseif ($input instanceof \TYPO3\CMS\Core\Type\TypeInterface) {
                        return (string) $input;
                } elseif (is_object($input)) {
                        if ($input instanceof \TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy) {