[+BUGFIX] Extbase (Persistence): The Storage Backend invokes t3lib_db::admin_get_fiel...
authorJochen Rau <j.rau@web.de>
Mon, 26 Oct 2009 17:03:19 +0000 (17:03 +0000)
committerJochen Rau <j.rau@web.de>
Mon, 26 Oct 2009 17:03:19 +0000 (17:03 +0000)
typo3/sysext/extbase/Classes/Persistence/Mapper/DataMapper.php
typo3/sysext/extbase/Classes/Persistence/Storage/Typo3DbBackend.php

index ada957c..23e8b03 100644 (file)
@@ -338,7 +338,8 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
 
        /**
         * Returns a data map for a given class name
-        *
+        * 
+        * @param string $className The class name you want to fetch the Data Map for
         * @return Tx_Extbase_Persistence_Mapper_DataMap The data map
         */
        public function getDataMap($className) {
@@ -356,7 +357,7 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
                                if (is_array($persistenceSettings['mapping']['columns'])) {
                                        $columnMapping = $persistenceSettings['mapping']['columns'];
                                }
-                       } else {
+                       } elseif (class_exists($className)) {
                                foreach (class_parents($className) as $parentClassName) {
                                        $persistenceSettings = $extbaseSettings['persistence']['classes'][$parentClassName];
                                        if (is_array($persistenceSettings)) {
@@ -369,8 +370,9 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
                                        }
                                        break;
                                }
+                       } else {
+                               throw new Tx_Extbase_Persistence_Exception('Could not determine a Data Map for given class name.', 1256067130);
                        }
-                       if (strlen($className) === 0) throw new Tx_Extbase_Persistence_Exception('Could not determine table name for given class.', 1256067130);
 
                        $dataMap = new Tx_Extbase_Persistence_Mapper_DataMap($className, $tableName, $columnMapping);
                        $this->dataMaps[$className] = $dataMap;
index b0d2c74..c43cc89 100644 (file)
@@ -549,7 +549,8 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         * @return void
         */
        protected function addPageIdStatement($tableName, array &$sql) {
-               if (is_array($GLOBALS['TCA'][$tableName]['ctrl']) && $this->dataMapper->getDataMap($tableName)->hasPidColumn()) {
+               $columns = $this->databaseHandle->admin_get_fields($tableName);         
+               if (is_array($GLOBALS['TCA'][$tableName]['ctrl']) && array_key_exists('pid', $columns)) {
                        $extbaseFrameworkConfiguration = Tx_Extbase_Dispatcher::getExtbaseFrameworkConfiguration();
                        $sql['additionalWhereClause'][] = $tableName . '.pid IN (' . implode(', ', t3lib_div::intExplode(',', $extbaseFrameworkConfiguration['persistence']['storagePid'])) . ')';
                }
@@ -713,7 +714,8 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                $pageIdsToClear = array();
                $storagePage = NULL;
 
-               if ($this->dataMapper->getDataMap($tableName)->hasPidColumn()) {
+               $columns = $this->databaseHandle->admin_get_fields($tableName);
+               if (array_key_exists('pid', $columns)) {
                        $result = $this->databaseHandle->exec_SELECTquery('pid', $tableName, 'uid='.intval($uid));
                        if ($row = $this->databaseHandle->sql_fetch_assoc($result))     {
                                $storagePage = $row['pid'];