[+BUGFIX] Extbase (Persistence): Fixed typo in Exception class.
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Storage / Typo3DbBackend.php
index ebd9f7e..6aecfd7 100644 (file)
@@ -172,7 +172,7 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         */
        public function getRows(Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query) {
                $statement = $this->parseQuery($query);
-//             debug($statement, -2); // FIXME remove debug code
+               // debug($statement, -2); // FIXME remove debug code
                $result = $this->databaseHandle->sql_query($statement);
                $this->checkSqlErrors();
                if ($result) {
@@ -235,9 +235,7 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                                $statement .= ' LIMIT ' . $sql['limit'];
                        }
                }
-
                $this->replacePlaceholders($statement, $parameters);
-               // debug($statement,-2);
                return $statement;
        }
 
@@ -362,6 +360,7 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         * @return void
         */
        protected function parseConstraint(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint = NULL, Tx_Extbase_Persistence_QOM_SourceInterface $source, array &$sql, array &$parameters, array $boundVariableValues) {
+               if ($constraint === NULL) return;
                if ($constraint instanceof Tx_Extbase_Persistence_QOM_AndInterface) {
                        $sql['where'][] = '(';
                        $this->parseConstraint($constraint->getConstraint1(), $source, $sql, $parameters, $boundVariableValues);
@@ -548,7 +547,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'])) {
+               $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'])) . ')';
                }
@@ -578,10 +578,11 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                                                throw new Tx_Extbase_Persistence_Exception_UnsupportedOrder('Unsupported order encountered.', 1242816074);
                                }
                                $tableName = $operand->getSelectorName();
-                               if ((strlen($tableName) == 0) && (source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface)) {
-                                       $tableName = $source->getSelectorName();
+                               $className = '';
+                               if ($source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
+                                       $className = $source->getNodeTypeName();
                                }
-                               $columnName = $this->dataMapper->convertPropertyNameToColumnName($operand->getPropertyName(), $tableName);
+                               $columnName = $this->dataMapper->convertPropertyNameToColumnName($operand->getPropertyName(), $className);
                                if (strlen($tableName) > 0) {
                                        $sql['orderings'][] = $tableName . '.' . $columnName . ' ' . $order;
                                } else {
@@ -711,13 +712,14 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                $pageIdsToClear = array();
                $storagePage = NULL;
 
-               if ($this->dataMapper->getDataMap($tableName)->hasPidColumn()) {
-                       $result = $this->databaseHandle->exec_SELECTquery('pid', $tableName, 'uid='.intval($uid)); {
+               $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'];
                                $pageIdsToClear[] = $storagePage;
                        }
-               } elseif(isset($GLOBALS['TSFE'])) {
+               } elseif (isset($GLOBALS['TSFE'])) {
                        // No PID column - we can do a best-effort to clear the cache of the current page if in FE
                        $storagePage = $GLOBALS['TSFE']->id;
                        $pageIdsToClear[] = $storagePage;