Merge "Skin::outputPage: Drop support for specifying a context, deprecated in 1.20"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 22 Jun 2019 20:24:25 +0000 (20:24 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 22 Jun 2019 20:24:25 +0000 (20:24 +0000)
includes/deferred/UserEditCountUpdate.php
includes/jobqueue/jobs/CategoryMembershipChangeJob.php
includes/jobqueue/jobs/ClearUserWatchlistJob.php
includes/libs/rdbms/loadbalancer/ILoadBalancer.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php
tests/phpunit/includes/GlobalFunctions/wfShellExecTest.php
tests/phpunit/includes/shell/CommandTest.php

index 4ce0b18..e9ebabb 100644 (file)
@@ -89,7 +89,7 @@ class UserEditCountUpdate implements DeferrableUpdate, MergeableUpdate {
                                                // This method runs after the new revisions were committed.
                                                // Wait for the replica to catch up so they will all be counted.
                                                $dbr->flushSnapshot( $fname );
-                                               $lb->safeWaitForMasterPos( $dbr );
+                                               $lb->waitForMasterPos( $dbr );
                                        }
                                        $affectedInstances[0]->initEditCountInternal();
                                }
index 3aedc38..be76fc6 100644 (file)
@@ -91,9 +91,9 @@ class CategoryMembershipChangeJob extends Job {
                        return false; // deleted?
                }
 
-               // Cut down on the time spent in safeWaitForMasterPos() in the critical section
+               // Cut down on the time spent in waitForMasterPos() in the critical section
                $dbr = $lb->getConnection( DB_REPLICA, [ 'recentchanges' ] );
-               if ( !$lb->safeWaitForMasterPos( $dbr ) ) {
+               if ( !$lb->waitForMasterPos( $dbr ) ) {
                        $this->setLastError( "Timed out while pre-waiting for replica DB to catch up" );
                        return false;
                }
@@ -107,7 +107,7 @@ class CategoryMembershipChangeJob extends Job {
                }
 
                // Wait till replica DB is caught up so that jobs for this page see each others' changes
-               if ( !$lb->safeWaitForMasterPos( $dbr ) ) {
+               if ( !$lb->waitForMasterPos( $dbr ) ) {
                        $this->setLastError( "Timed out while waiting for replica DB to catch up" );
                        return false;
                }
index 0cb1a52..1793053 100644 (file)
@@ -44,7 +44,7 @@ class ClearUserWatchlistJob extends Job implements GenericParameterJob {
                $dbr = $loadBalancer->getConnection( DB_REPLICA, [ 'watchlist' ] );
 
                // Wait before lock to try to reduce time waiting in the lock.
-               if ( !$loadBalancer->safeWaitForMasterPos( $dbr ) ) {
+               if ( !$loadBalancer->waitForMasterPos( $dbr ) ) {
                        $this->setLastError( 'Timed out waiting for replica to catch up before lock' );
                        return false;
                }
@@ -57,7 +57,7 @@ class ClearUserWatchlistJob extends Job implements GenericParameterJob {
                        return false;
                }
 
-               if ( !$loadBalancer->safeWaitForMasterPos( $dbr ) ) {
+               if ( !$loadBalancer->waitForMasterPos( $dbr ) ) {
                        $this->setLastError( 'Timed out waiting for replica to catch up within lock' );
                        return false;
                }
index f0d071b..4d148b4 100644 (file)
@@ -649,8 +649,9 @@ interface ILoadBalancer {
         * @param DBMasterPos|bool $pos Master position; default: current position
         * @param int $timeout Timeout in seconds [optional]
         * @return bool Success
+        * @since 1.34
         */
-       public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = 10 );
+       public function waitForMasterPos( IDatabase $conn, $pos = false, $timeout = 10 );
 
        /**
         * Set a callback via IDatabase::setTransactionListener() on
index 3936271..c08655c 100644 (file)
@@ -1994,7 +1994,7 @@ class LoadBalancer implements ILoadBalancer {
                return $conn->getLag();
        }
 
-       public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = null ) {
+       public function waitForMasterPos( IDatabase $conn, $pos = false, $timeout = null ) {
                $timeout = max( 1, $timeout ?: $this->waitTimeout );
 
                if ( $this->getServerCount() <= 1 || !$conn->getLBInfo( 'replica' ) ) {
@@ -2052,6 +2052,22 @@ class LoadBalancer implements ILoadBalancer {
                return $ok;
        }
 
+       /**
+        * Wait for a replica DB to reach a specified master position
+        *
+        * This will connect to the master to get an accurate position if $pos is not given
+        *
+        * @param IDatabase $conn Replica DB
+        * @param DBMasterPos|bool $pos Master position; default: current position
+        * @param int $timeout Timeout in seconds [optional]
+        * @return bool Success
+        * @since 1.28
+        * @deprecated Since 1.34 Use waitForMasterPos() instead
+        */
+       public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = null ) {
+               return $this->waitForMasterPos( $conn, $pos, $timeout );
+       }
+
        public function setTransactionListener( $name, callable $callback = null ) {
                if ( $callback ) {
                        $this->trxRecurringCallbacks[$name] = $callback;
index 6279cf6..68bb1e9 100644 (file)
@@ -6,14 +6,17 @@
  */
 class WfShellExecTest extends MediaWikiTestCase {
        public function testT69870() {
-               $command = wfIsWindows()
-                       // 333 = 331 + CRLF
-                       ? ( 'for /l %i in (1, 1, 1001) do @echo ' . str_repeat( '*', 331 ) )
-                       : 'printf "%-333333s" "*"';
+               if ( wfIsWindows() ) {
+                       // T209159: Anonymous pipe under Windows does not support asynchronous read and write,
+                       // and the default buffer is too small (~4K), it is easy to be blocked.
+                       $this->markTestSkipped(
+                               'T209159: Anonymous pipe under Windows cannot withstand such a large amount of data'
+                       );
+               }
 
                // Test several times because it involves a race condition that may randomly succeed or fail
                for ( $i = 0; $i < 10; $i++ ) {
-                       $output = wfShellExec( $command );
+                       $output = wfShellExec( 'printf "%-333333s" "*"' );
                        $this->assertEquals( 333333, strlen( $output ) );
                }
        }
index 2e03163..c5e8e89 100644 (file)
@@ -119,15 +119,18 @@ class CommandTest extends PHPUnit\Framework\TestCase {
        }
 
        public function testT69870() {
-               $commandLine = wfIsWindows()
-                       // 333 = 331 + CRLF
-                       ? ( 'for /l %i in (1, 1, 1001) do @echo ' . str_repeat( '*', 331 ) )
-                       : 'printf "%-333333s" "*"';
+               if ( wfIsWindows() ) {
+                       // T209159: Anonymous pipe under Windows does not support asynchronous read and write,
+                       // and the default buffer is too small (~4K), it is easy to be blocked.
+                       $this->markTestSkipped(
+                               'T209159: Anonymous pipe under Windows cannot withstand such a large amount of data'
+                       );
+               }
 
                // Test several times because it involves a race condition that may randomly succeed or fail
                for ( $i = 0; $i < 10; $i++ ) {
                        $command = new Command();
-                       $output = $command->unsafeParams( $commandLine )
+                       $output = $command->unsafeParams( 'printf "%-333333s" "*"' )
                                ->execute()
                                ->getStdout();
                        $this->assertEquals( 333333, strlen( $output ) );