Rename DB_SLAVE constant to DB_REPLICA
[lhc/web/wiklou.git] / maintenance / storage / recompressTracked.php
index 2f414df..0a62103 100644 (file)
@@ -59,7 +59,7 @@ class RecompressTracked {
        public $reportingInterval = 10;
        public $numProcs = 1;
        public $numBatches = 0;
-       public $useDiff, $pageBlobClass, $orphanBlobClass;
+       public $pageBlobClass, $orphanBlobClass;
        public $slavePipes, $slaveProcs, $prevSlaveId;
        public $copyOnly = false;
        public $isChild = false;
@@ -112,8 +112,8 @@ class RecompressTracked {
                } elseif ( $this->slaveId !== false ) {
                        $GLOBALS['wgDebugLogPrefix'] = "RCT {$this->slaveId}: ";
                }
-               $this->useDiff = function_exists( 'xdiff_string_bdiff' );
-               $this->pageBlobClass = $this->useDiff ? 'DiffHistoryBlob' : 'ConcatenatedGzipHistoryBlob';
+               $this->pageBlobClass = function_exists( 'xdiff_string_bdiff' ) ?
+                       'DiffHistoryBlob' : 'ConcatenatedGzipHistoryBlob';
                $this->orphanBlobClass = 'ConcatenatedGzipHistoryBlob';
        }
 
@@ -148,13 +148,13 @@ class RecompressTracked {
        }
 
        /**
-        * Wait until the selected slave has caught up to the master.
-        * This allows us to use the slave for things that were committed in a
+        * Wait until the selected replica DB has caught up to the master.
+        * This allows us to use the replica DB for things that were committed in a
         * previous part of this batch process.
         */
        function syncDBs() {
                $dbw = wfGetDB( DB_MASTER );
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
                $pos = $dbw->getMasterPos();
                $dbr->masterPosWait( $pos, 100000 );
        }
@@ -190,7 +190,7 @@ class RecompressTracked {
         * @return bool
         */
        function checkTrackingTable() {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
                if ( !$dbr->tableExists( 'blob_tracking' ) ) {
                        $this->critical( "Error: blob_tracking table does not exist" );
 
@@ -239,7 +239,7 @@ class RecompressTracked {
                        $proc = proc_open( "$cmd --slave-id $i", $spec, $pipes );
                        MediaWiki\restoreWarnings();
                        if ( !$proc ) {
-                               $this->critical( "Error opening slave process: $cmd" );
+                               $this->critical( "Error opening replica DB process: $cmd" );
                                exit( 1 );
                        }
                        $this->slaveProcs[$i] = $proc;
@@ -252,7 +252,7 @@ class RecompressTracked {
         * Gracefully terminate the child processes
         */
        function killSlaveProcs() {
-               $this->info( "Waiting for slave processes to finish..." );
+               $this->info( "Waiting for replica DB processes to finish..." );
                for ( $i = 0; $i < $this->numProcs; $i++ ) {
                        $this->dispatchToSlave( $i, 'quit' );
                }
@@ -266,15 +266,15 @@ class RecompressTracked {
        }
 
        /**
-        * Dispatch a command to the next available slave.
-        * This may block until a slave finishes its work and becomes available.
+        * Dispatch a command to the next available replica DB.
+        * This may block until a replica DB finishes its work and becomes available.
         */
        function dispatch( /*...*/ ) {
                $args = func_get_args();
                $pipes = $this->slavePipes;
                $numPipes = stream_select( $x = [], $pipes, $y = [], 3600 );
                if ( !$numPipes ) {
-                       $this->critical( "Error waiting to write to slaves. Aborting" );
+                       $this->critical( "Error waiting to write to replica DBs. Aborting" );
                        exit( 1 );
                }
                for ( $i = 0; $i < $this->numProcs; $i++ ) {
@@ -291,7 +291,7 @@ class RecompressTracked {
        }
 
        /**
-        * Dispatch a command to a specified slave
+        * Dispatch a command to a specified replica DB
         * @param int $slaveId
         * @param array|string $args
         */
@@ -305,7 +305,7 @@ class RecompressTracked {
         * Move all tracked pages to the new clusters
         */
        function doAllPages() {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
                $i = 0;
                $startId = 0;
                if ( $this->noCount ) {
@@ -374,7 +374,7 @@ class RecompressTracked {
         * Move all orphan text to the new clusters
         */
        function doAllOrphans() {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
                $startId = 0;
                $i = 0;
                if ( $this->noCount ) {
@@ -480,7 +480,7 @@ class RecompressTracked {
                } else {
                        $titleText = '[deleted]';
                }
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
 
                // Finish any incomplete transactions
                if ( !$this->copyOnly ) {
@@ -590,7 +590,7 @@ class RecompressTracked {
         * @param array $conds
         */
        function finishIncompleteMoves( $conds ) {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
 
                $startId = 0;
                $conds = array_merge( $conds, [
@@ -659,7 +659,7 @@ class RecompressTracked {
 
                $trx = new CgzCopyTransaction( $this, $this->orphanBlobClass );
 
-               $res = wfGetDB( DB_SLAVE )->select(
+               $res = wfGetDB( DB_REPLICA )->select(
                        [ 'text', 'blob_tracking' ],
                        [ 'old_id', 'old_text', 'old_flags' ],
                        [
@@ -762,7 +762,7 @@ class CgzCopyTransaction {
 
                /* Check to see if the target text_ids have been moved already.
                 *
-                * We originally read from the slave, so this can happen when a single
+                * We originally read from the replica DB, so this can happen when a single
                 * text_id is shared between multiple pages. It's rare, but possible
                 * if a delete/move/undelete cycle splits up a null edit.
                 *