summaryrefslogtreecommitdiff
path: root/maintenance/syncFileBackend.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-12-27 15:41:37 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-12-31 11:43:28 +0100
commitc1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch)
tree2b38796e738dd74cb42ecd9bfd151803108386bc /maintenance/syncFileBackend.php
parentb88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff)
Update to MediaWiki 1.24.1
Diffstat (limited to 'maintenance/syncFileBackend.php')
-rw-r--r--maintenance/syncFileBackend.php31
1 files changed, 19 insertions, 12 deletions
diff --git a/maintenance/syncFileBackend.php b/maintenance/syncFileBackend.php
index f0be709f..14a1502f 100644
--- a/maintenance/syncFileBackend.php
+++ b/maintenance/syncFileBackend.php
@@ -71,6 +71,7 @@ class SyncFileBackend extends Maintenance {
if ( $this->isQuiet() ) {
print $id; // give a single machine-readable number
}
+
return;
}
@@ -104,7 +105,7 @@ class SyncFileBackend extends Maintenance {
}
// Periodically update the position file
- $callback = function( $pos ) use ( $startFromPosFile, $posFile, $start ) {
+ $callback = function ( $pos ) use ( $startFromPosFile, $posFile, $start ) {
if ( $startFromPosFile && $pos >= $start ) { // successfully advanced
file_put_contents( $posFile, $pos, LOCK_EX );
}
@@ -141,12 +142,12 @@ class SyncFileBackend extends Maintenance {
* Sync $dst backend to $src backend based on the $src logs given after $start.
* Returns the journal entry ID this advanced to and handled (inclusive).
*
- * @param $src FileBackend
- * @param $dst FileBackend
- * @param $start integer Starting journal position
- * @param $end integer Starting journal position
- * @param $callback Closure Callback to update any position file
- * @return integer|false Journal entry ID or false if there are none
+ * @param FileBackend $src
+ * @param FileBackend $dst
+ * @param int $start Starting journal position
+ * @param int $end Starting journal position
+ * @param Closure $callback Callback to update any position file
+ * @return int|bool Journal entry ID or false if there are none
*/
protected function syncBackends(
FileBackend $src, FileBackend $dst, $start, $end, Closure $callback
@@ -198,9 +199,9 @@ class SyncFileBackend extends Maintenance {
/**
* Sync particular files of backend $src to the corresponding $dst backend files
*
- * @param $paths Array
- * @param $src FileBackend
- * @param $dst FileBackend
+ * @param array $paths
+ * @param FileBackend $src
+ * @param FileBackend $dst
* @return Status
*/
protected function syncFileBatch( array $paths, FileBackend $src, FileBackend $dst ) {
@@ -221,6 +222,9 @@ class SyncFileBackend extends Maintenance {
return $status;
}
+ $src->preloadFileStat( array( 'srcs' => $sPaths, 'latest' => 1 ) );
+ $dst->preloadFileStat( array( 'srcs' => $dPaths, 'latest' => 1 ) );
+
$ops = array();
$fsFiles = array();
foreach ( $sPaths as $i => $sPath ) {
@@ -235,6 +239,7 @@ class SyncFileBackend extends Maintenance {
if ( !$fsFile ) {
$this->error( "Unable to sync '$dPath': could not get local copy." );
$status->fatal( 'backend-fail-internal', $src->getName() );
+
return $status;
}
$fsFiles[] = $fsFile; // keep TempFSFile objects alive as needed
@@ -251,6 +256,7 @@ class SyncFileBackend extends Maintenance {
} else { // error
$this->error( "Unable to sync '$dPath': could not stat file." );
$status->fatal( 'backend-fail-internal', $src->getName() );
+
return $status;
}
}
@@ -273,8 +279,9 @@ class SyncFileBackend extends Maintenance {
/**
* Substitute the backend name of storage paths with that of a given one
*
- * @param $paths Array|string List of paths or single string path
- * @return Array|string
+ * @param array|string $paths List of paths or single string path
+ * @param FileBackend $backend
+ * @return array|string
*/
protected function replaceNamePaths( $paths, FileBackend $backend ) {
return preg_replace(