Fixed unnecessary cache clearing
authorAlexander Ebert <ebert@woltlab.com>
Wed, 9 Jan 2013 20:31:03 +0000 (21:31 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 9 Jan 2013 20:31:03 +0000 (21:31 +0100)
wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php

index 9119324b6599933561a2b51d6cc7e10c933817f6..39c246423272df75cac10e0a43ca99ac33ac5dcc 100644 (file)
@@ -68,6 +68,12 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID
         */
        protected $permissionsUpdate = array();
        
+       /**
+        * Resets cache if any of the listed actions is invoked
+        * @var array<string>
+        */
+       protected $resetCache = array('create', 'delete', 'toggle', 'update', 'updatePosition');
+       
        /**
         * values returned by executed action
         * @var mixed
@@ -166,8 +172,8 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID
                $this->returnValues = call_user_func(array($this, $this->getActionName()));
                
                // reset cache
-               if (ClassUtil::isInstanceOf($this->className, 'wcf\data\IEditableCachedObject')) {
-                       call_user_func(array($this->className, 'resetCache'));
+               if (in_array($this->getActionName(), $this->resetCache)) {
+                       $this->resetCache();
                }
                
                // fire event action
@@ -176,6 +182,15 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID
                return $this->getReturnValues();
        }
        
+       /**
+        * Resets cache of database object.
+        */
+       protected function resetCache() {
+               if (ClassUtil::isInstanceOf($this->className, 'wcf\data\IEditableCachedObject')) {
+                       call_user_func(array($this->className, 'resetCache'));
+               }
+       }
+       
        /**
         * @see wcf\data\IDatabaseObjectAction::getActionName()
         */