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

Revision: 106332
Author:   aaron
Date:     2011-12-15 16:23:12 +0000 (Thu, 15 Dec 2011)
Log Message:
-----------
Renamed FileBackendBase::attemptOperations() to FileOp::attemptBatch()

Modified Paths:
--------------
    branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php
    
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/FileBackend.php
===================================================================
--- branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php       
2011-12-15 15:48:23 UTC (rev 106331)
+++ branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php       
2011-12-15 16:23:12 UTC (rev 106332)
@@ -150,77 +150,6 @@
        }
 
        /**
-        * Attempt a series of file operations.
-        * Callers are responsible for handling file locking.
-        * 
-        * @param $performOps Array List of FileOp operations
-        * @return Status 
-        */
-       protected function attemptOperations( array $performOps ) {
-               $status = Status::newGood();
-
-               $predicates = FileOp::newPredicates(); // account for previous 
op in prechecks
-               // Do pre-checks for each operation; abort on failure...
-               foreach ( $performOps as $index => $fileOp ) {
-                       $status->merge( $fileOp->precheck( $predicates ) );
-                       if ( !$status->isOK() ) { // operation failed?
-                               if ( $fileOp->getParam( 'ignoreErrors' ) ) {
-                                       ++$status->failCount;
-                                       $status->success[$index] = false;
-                               } else {
-                                       return $status;
-                               }
-                       }
-               }
-
-               // Attempt each operation; abort on failure...
-               foreach ( $performOps as $index => $fileOp ) {
-                       if ( $fileOp->failed() ) {
-                               continue; // nothing to do
-                       }
-                       $status->merge( $fileOp->attempt() );
-                       if ( !$status->isOK() ) { // operation failed?
-                               if ( $fileOp->getParam( 'ignoreErrors' ) ) {
-                                       ++$status->failCount;
-                                       $status->success[$index] = false;
-                               } else {
-                                       // Revert everything done so far and 
abort.
-                                       // Do this by reverting each previous 
operation in reverse order.
-                                       $pos = $index - 1; // last one failed; 
no need to revert()
-                                       while ( $pos >= 0 ) {
-                                               if ( 
!$performOps[$pos]->failed() ) {
-                                                       $status->merge( 
$performOps[$pos]->revert() );
-                                               }
-                                               $pos--;
-                                       }
-                                       return $status;
-                               }
-                       }
-               }
-
-               // Finish each operation...
-               foreach ( $performOps as $index => $fileOp ) {
-                       if ( $fileOp->failed() ) {
-                               continue; // nothing to do
-                       }
-                       $subStatus = $fileOp->finish();
-                       if ( $subStatus->isOK() ) {
-                               ++$status->successCount;
-                               $status->success[$index] = true;
-                       } else {
-                               ++$status->failCount;
-                               $status->success[$index] = false;
-                       }
-                       $status->merge( $subStatus );
-               }
-
-               // Make sure status is OK, despite any finish() fatals
-               $status->setResult( true, $status->value );
-
-               return $status;
-       }
-
-       /**
         * Prepare a storage path for usage. This will create containers
         * that don't yet exist or, on FS backends, create parent directories.
         * 
@@ -640,7 +569,7 @@
                }
 
                // Actually attempt the operation batch...
-               $status->merge( $this->attemptOperations( $performOps ) );
+               $status->merge( FileOp::attemptBatch( $performOps ) );
 
                return $status;
        }

Modified: 
branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php
===================================================================
--- 
branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php 
    2011-12-15 15:48:23 UTC (rev 106331)
+++ 
branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php 
    2011-12-15 16:23:12 UTC (rev 106332)
@@ -93,7 +93,7 @@
                }
 
                // Actually attempt the operation batch...
-               $status->merge( $this->attemptOperations( $performOps ) );
+               $status->merge( FileOp::attemptBatch( $performOps ) );
 
                return $status;
        }

Modified: branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php
===================================================================
--- branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php    
2011-12-15 15:48:23 UTC (rev 106331)
+++ branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php    
2011-12-15 16:23:12 UTC (rev 106332)
@@ -53,6 +53,77 @@
        }
 
        /**
+        * Attempt a series of file operations.
+        * Callers are responsible for handling file locking.
+        * 
+        * @param $performOps Array List of FileOp operations
+        * @return Status 
+        */
+       public static function attemptBatch( array $performOps ) {
+               $status = Status::newGood();
+
+               $predicates = FileOp::newPredicates(); // account for previous 
op in prechecks
+               // Do pre-checks for each operation; abort on failure...
+               foreach ( $performOps as $index => $fileOp ) {
+                       $status->merge( $fileOp->precheck( $predicates ) );
+                       if ( !$status->isOK() ) { // operation failed?
+                               if ( $fileOp->getParam( 'ignoreErrors' ) ) {
+                                       ++$status->failCount;
+                                       $status->success[$index] = false;
+                               } else {
+                                       return $status;
+                               }
+                       }
+               }
+
+               // Attempt each operation; abort on failure...
+               foreach ( $performOps as $index => $fileOp ) {
+                       if ( $fileOp->failed() ) {
+                               continue; // nothing to do
+                       }
+                       $status->merge( $fileOp->attempt() );
+                       if ( !$status->isOK() ) { // operation failed?
+                               if ( $fileOp->getParam( 'ignoreErrors' ) ) {
+                                       ++$status->failCount;
+                                       $status->success[$index] = false;
+                               } else {
+                                       // Revert everything done so far and 
abort.
+                                       // Do this by reverting each previous 
operation in reverse order.
+                                       $pos = $index - 1; // last one failed; 
no need to revert()
+                                       while ( $pos >= 0 ) {
+                                               if ( 
!$performOps[$pos]->failed() ) {
+                                                       $status->merge( 
$performOps[$pos]->revert() );
+                                               }
+                                               $pos--;
+                                       }
+                                       return $status;
+                               }
+                       }
+               }
+
+               // Finish each operation...
+               foreach ( $performOps as $index => $fileOp ) {
+                       if ( $fileOp->failed() ) {
+                               continue; // nothing to do
+                       }
+                       $subStatus = $fileOp->finish();
+                       if ( $subStatus->isOK() ) {
+                               ++$status->successCount;
+                               $status->success[$index] = true;
+                       } else {
+                               ++$status->failCount;
+                               $status->success[$index] = false;
+                       }
+                       $status->merge( $subStatus );
+               }
+
+               // Make sure status is OK, despite any finish() fatals
+               $status->setResult( true, $status->value );
+
+               return $status;
+       }
+
+       /**
         * Get the value of the parameter with the given name.
         * Returns null if the parameter is not set.
         * 

Modified: branches/FileBackend/phase3/includes/filerepo/backend/LockManager.php
===================================================================
--- branches/FileBackend/phase3/includes/filerepo/backend/LockManager.php       
2011-12-15 15:48:23 UTC (rev 106331)
+++ branches/FileBackend/phase3/includes/filerepo/backend/LockManager.php       
2011-12-15 16:23:12 UTC (rev 106332)
@@ -132,7 +132,7 @@
                $wasOk = $this->status->isOK();
                $this->status->merge( $this->manager->unlock( $this->paths, 
$this->type ) );
                if ( $wasOk ) {
-                       // Make sure status is OK, despite any unlockFiles() 
fatals     
+                       // Make sure status is OK, despite any unlockFiles() 
fatals
                        $this->status->setResult( true, $this->status->value );
                }
        }
@@ -767,7 +767,7 @@
                                array( 'fle_key' => $keys ),
                                __METHOD__
                        );
-                       # Prospective writers that haven't yet update 
filelocks_exclusive
+                       # Prospective writers that haven't yet updated 
filelocks_exclusive
                        # will recheck filelocks_shared after doing so and bail 
due to our entry.
                } else { // writer locks
                        $encSession = $db->addQuotes( $this->session );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to