Merge "Fix spacing in SpecialRevisiondelete.php"
[lhc/web/wiklou.git] / includes / PoolCounter.php
index 38c6f04..85c4c79 100644 (file)
@@ -91,6 +91,13 @@ abstract class PoolCounter {
                return new $class( $conf, $type, $key );
        }
 
+       /**
+        * @return string
+        */
+       public function getKey() {
+               return $this->key;
+       }
+
        /**
         * I want to do this task and I need to do it myself.
         *
@@ -175,7 +182,7 @@ abstract class PoolCounterWork {
         * Do something with the error, like showing it to the user.
         * @return bool
         */
-       function error( $status ) {
+       public function error( $status ) {
                return false;
        }
 
@@ -185,14 +192,27 @@ abstract class PoolCounterWork {
         * @param $status Status
         * @return void
         */
-       function logError( $status ) {
-               wfDebugLog( 'poolcounter', $status->getWikiText() );
+       public function logError( $status ) {
+               $key = $this->poolCounter->getKey();
+
+               wfDebugLog( 'poolcounter', "Pool key '$key': "
+                       . $status->getMessage()->inLanguage( 'en' )->useDatabase( false )->text() );
        }
 
        /**
-        * Get the result of the work (whatever it is), or false.
+        * Get the result of the work (whatever it is), or the result of the error() function.
+        * This returns the result of the first applicable method that returns a non-false value,
+        * where the methods are checked in the following order:
+        *   - a) doWork()       : Applies if the work is exclusive or no another process
+        *                         is doing it, and on the condition that either this process
+        *                         successfully entered the pool or the pool counter is down.
+        *   - b) doCachedWork() : Applies if the work is cacheable and this blocked on another
+        *                         process which finished the work.
+        *   - c) fallback()     : Applies for all remaining cases.
+        * If these all fall through (by returning false), then the result of error() is returned.
+        *
         * @param $skipcache bool
-        * @return bool|mixed
+        * @return mixed
         */
        public function execute( $skipcache = false ) {
                if ( $this->cacheable && !$skipcache ) {
@@ -303,14 +323,14 @@ class PoolCounterWorkViaCallback extends PoolCounterWork {
                return false;
        }
 
-       function fallback() {
+       public function fallback() {
                if ( $this->fallback ) {
                        return call_user_func_array( $this->fallback, array() );
                }
                return false;
        }
 
-       function error( $status ) {
+       public function error( $status ) {
                if ( $this->error ) {
                        return call_user_func_array( $this->error, array( $status ) );
                }