Extbase:
authorSebastian Kurfürst <sebastian@typo3.org>
Tue, 14 Jul 2009 18:32:18 +0000 (18:32 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Tue, 14 Jul 2009 18:32:18 +0000 (18:32 +0000)
* Fixed issue that cache is tried to be cleared even if a relation is changed

typo3/sysext/extbase/Classes/Persistence/Backend.php
typo3/sysext/extbase/Classes/Persistence/Storage/BackendInterface.php
typo3/sysext/extbase/Classes/Persistence/Storage/Typo3DbBackend.php

index 18ccce0..473b782 100644 (file)
@@ -313,7 +313,7 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                if ($object->_isNew()) {
                        $this->insertObject($object, $parentObject, $parentPropertyName, $row);
                } elseif ($object->_isDirty()) {
-                               $this->updateObject($object, $parentObject, $parentPropertyName, $row);
+                       $this->updateObject($object, $parentObject, $parentPropertyName, $row);
                }
                
                // SK: I need to check the code below more thoroughly
@@ -396,8 +396,8 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                $tableName = $dataMap->getColumnMap($parentPropertyName)->getRelationTableName();
                $res = $this->storageBackend->addRow(
                        $tableName,
-                       $row
-                       );
+                       $row,
+                       TRUE);
                return $res;
        }
 
@@ -551,6 +551,7 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                                foreach ($relatedObjects as $relatedObject) {
                                        $this->deleteObject($relatedObject, $object, $propertyName);
                                        if ($dataMap->getColumnMap($propertyName)->getTypeOfRelation() === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY) {
+                                               // SK: This method does IMHO not exist.
                                                $this->deleteRelationInRelationTable($relatedObject, $object, $propertyName);
                                        }
                                }
index 140dd83..dfbfbce 100644 (file)
@@ -39,27 +39,30 @@ interface Tx_Extbase_Persistence_Storage_BackendInterface {
         *
         * @param string $tableName The database table name
         * @param array $row The row to insert
+        * @param boolean $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
         * @return void
         */
-       public function addRow($tableName, array $row);
+       public function addRow($tableName, array $row, $isRelation = FALSE);
 
        /**
         * Updates a row in the storage
         *
         * @param string $tableName The database table name
         * @param array $row The row to update
+        * @param boolean $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
         * @return void
         */
-       public function updateRow($tableName, array $row);
+       public function updateRow($tableName, array $row, $isRelation = FALSE);
 
        /**
         * Deletes a row in the storage
         *
         * @param string $tableName The database table name
         * @param int $uid The uid of the row to delete
+        * @param boolean $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
         * @return void
         */
-       public function removeRow($tableName, $uid);
+       public function removeRow($tableName, $uid, $isRelation = FALSE);
 
        /**
         * Returns an array with rows matching the query.
index 37dee61..4dc1ec8 100644 (file)
@@ -91,9 +91,10 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         *
         * @param string $tableName The database table name
         * @param array $row The row to be inserted
+        * @param boolean $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
         * @return int The uid of the inserted row
         */
-       public function addRow($tableName, array $row) {
+       public function addRow($tableName, array $row, $isRelation = FALSE) {
                $fields = array();
                $values = array();
                $parameters = array();
@@ -109,7 +110,9 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
 
                $this->databaseHandle->sql_query($sqlString);
                $uid = $this->databaseHandle->sql_insert_id();
-               $this->clearPageCache($tableName, $uid);
+               if (!$isRelation) {
+                       $this->clearPageCache($tableName, $uid);
+               }
                return $uid;
        }
 
@@ -118,9 +121,10 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         *
         * @param string $tableName The database table name
         * @param array $row The row to be updated
+        * @param boolean $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
         * @return void
         */
-       public function updateRow($tableName, array $row) {
+       public function updateRow($tableName, array $row, $isRelation = FALSE) {
                if (!isset($row['uid'])) throw new InvalidArgumentException('The given row must contain a value for "uid".');
                $uid = (int)$row['uid'];
                unset($row['uid']);
@@ -136,7 +140,9 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                $this->replacePlaceholders($sqlString, $parameters);
 
                $returnValue = $this->databaseHandle->sql_query($sqlString);
-               $this->clearPageCache($tableName, $uid);
+               if (!$isRelation) {
+                       $this->clearPageCache($tableName, $uid);
+               }
                return $returnValue;
        }
 
@@ -145,12 +151,15 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         *
         * @param string $tableName The database table name
         * @param array $uid The uid of the row to be deleted
+        * @param boolean $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
         * @return void
         */
-       public function removeRow($tableName, $uid) {
+       public function removeRow($tableName, $uid, $isRelation = FALSE) {
                $sqlString = 'DELETE FROM ' . $tableName . ' WHERE uid=?';
                $this->replacePlaceholders($sqlString, array((int)$uid));
-               $this->clearPageCache($tableName, $uid);
+               if (!$isRelation) {
+                       $this->clearPageCache($tableName, $uid, $isRelation);
+               }
                $returnValue = $this->databaseHandle->sql_query($sqlString);
                return $returnValue;
        }