https://www.mediawiki.org/wiki/Special:Code/MediaWiki/106408

Revision: 106408
Author:   aaron
Date:     2011-12-16 03:38:45 +0000 (Fri, 16 Dec 2011)
Log Message:
-----------
Use FileOperation log to record operation failures...might be useful for 
recovery

Modified Paths:
--------------
    
branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php
    branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php
    branches/FileBackend/phase3/includes/filerepo/backend/LockManager.php

Modified: 
branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php
===================================================================
--- 
branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php 
    2011-12-16 03:34:36 UTC (rev 106407)
+++ 
branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php 
    2011-12-16 03:38:45 UTC (rev 106408)
@@ -35,7 +35,7 @@
         *     'backends'    : Array of backend config and multi-backend 
settings.
         *                     Each value is the config used in the constructor 
of a
         *                     FileBackend class, but with these additional 
settings:
-        *                                                 'class'        : The 
name of the backend class
+        *                         'class'        : The name of the backend 
class
         *                         'isMultiMaster': This must be set for one 
non-persistent backend.
         * @param $config Array
         */

Modified: branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php
===================================================================
--- branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php    
2011-12-16 03:34:36 UTC (rev 106407)
+++ branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php    
2011-12-16 03:38:45 UTC (rev 106408)
@@ -184,6 +184,7 @@
                $status = $this->doAttempt();
                if ( !$status->isOK() ) {
                        $this->failed = true;
+                       $this->logFailure( 'attempt' );
                }
                return $status;
        }
@@ -202,6 +203,9 @@
                        $status = Status::newGood(); // nothing to revert
                } else {
                        $status = $this->doRevert();
+                       if ( !$status->isOK() ) {
+                               $this->logFailure( 'revert' );
+                       }
                }
                return $status;
        }
@@ -465,6 +469,33 @@
                        return $this->backend->fileExists( array( 'src' => 
$source ) );
                }
        }
+
+       /**
+        * Log a file operation failure and preserve any temp files
+        * 
+        * @param $fileOp FileOp
+        * @return void
+        */
+       final protected function logFailure( $action ) {
+               $params = $this->params;
+               $params['failedAction'] = $action;
+               // Preserve backup files just in case (for recovery)
+               if ( $this->tmpSourceFile ) {
+                       $this->tmpSourceFile->preserve(); // don't purge
+                       $params['srcBackupPath'] = 
$this->tmpSourceFile->getPath();
+               }
+               if ( $this->tmpDestFile ) {
+                       $this->tmpDestFile->preserve(); // don't purge
+                       $params['dstBackupPath'] = 
$this->tmpDestFile->getPath();
+               }
+               try {
+                       wfDebugLog( 'FileOperation',
+                               get_class( $this ) . ' failed:' . serialize( 
$params ) );
+               } catch ( Exception $e ) {
+                       // bad config? debug log error?
+               }
+       }
+
 }
 
 /**

Modified: branches/FileBackend/phase3/includes/filerepo/backend/LockManager.php
===================================================================
--- branches/FileBackend/phase3/includes/filerepo/backend/LockManager.php       
2011-12-16 03:34:36 UTC (rev 106407)
+++ branches/FileBackend/phase3/includes/filerepo/backend/LockManager.php       
2011-12-16 03:38:45 UTC (rev 106408)
@@ -700,7 +700,7 @@
         * @return string
         */
        protected function getMissKey( $lockDb ) {
-               return "lockmanager:querymisses:$lockDb";
+               return 'lockmanager:querymisses:' . str_replace( ' ', '_', 
$lockDb );
        }
 
        /**


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to