Merge "rdbms: make getMasterPos() ignore GTIDs outside of gtid_domain_id"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 23 Mar 2018 00:03:20 +0000 (00:03 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 23 Mar 2018 00:03:20 +0000 (00:03 +0000)
includes/libs/rdbms/database/DBConnRef.php
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/IDatabase.php
includes/libs/rdbms/database/IMaintainableDatabase.php
includes/libs/rdbms/database/MaintainableDBConnRef.php
includes/user/User.php
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.MarkSeenButtonWidget.js
tests/phpunit/includes/user/UserTest.php

index 24bab7d..11ce957 100644 (file)
@@ -211,10 +211,6 @@ class DBConnRef implements IDatabase {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
 
-       public function fieldInfo( $table, $field ) {
-               return $this->__call( __FUNCTION__, func_get_args() );
-       }
-
        public function affectedRows() {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
@@ -231,18 +227,10 @@ class DBConnRef implements IDatabase {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
 
-       public function reportConnectionError( $error = 'Unknown error' ) {
-               return $this->__call( __FUNCTION__, func_get_args() );
-       }
-
        public function query( $sql, $fname = __METHOD__, $tempIgnore = false ) {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
 
-       public function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) {
-               return $this->__call( __FUNCTION__, func_get_args() );
-       }
-
        public function freeResult( $res ) {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
@@ -304,10 +292,6 @@ class DBConnRef implements IDatabase {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
 
-       public function indexUnique( $table, $index ) {
-               return $this->__call( __FUNCTION__, func_get_args() );
-       }
-
        public function insert( $table, $a, $fname = __METHOD__, $options = [] ) {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
@@ -545,10 +529,6 @@ class DBConnRef implements IDatabase {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
 
-       public function listTables( $prefix = null, $fname = __METHOD__ ) {
-               return $this->__call( __FUNCTION__, func_get_args() );
-       }
-
        public function timestamp( $ts = 0 ) {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
index 118e714..211566e 100644 (file)
@@ -912,6 +912,10 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
         */
        abstract protected function closeConnection();
 
+       /**
+        * @param string $error Fallback error message, used if none is given by DB
+        * @throws DBConnectionError
+        */
        public function reportConnectionError( $error = 'Unknown error' ) {
                $myError = $this->lastError();
                if ( $myError ) {
@@ -1287,6 +1291,17 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                return false;
        }
 
+       /**
+        * Report a query error. Log the error, and if neither the object ignore
+        * flag nor the $tempIgnore flag is set, throw a DBQueryError.
+        *
+        * @param string $error
+        * @param int $errno
+        * @param string $sql
+        * @param string $fname
+        * @param bool $tempIgnore
+        * @throws DBQueryError
+        */
        public function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) {
                if ( $this->ignoreErrors() || $tempIgnore ) {
                        $this->queryLogger->debug( "SQL ERROR (ignored): $error\n" );
index cd2bbf6..07f1e23 100644 (file)
@@ -233,6 +233,7 @@ interface IDatabase {
         * Should return true if unsure.
         *
         * @return bool
+        * @deprecated Since 1.31; use lastDoneWrites()
         */
        public function doneWrites();
 
@@ -459,17 +460,6 @@ interface IDatabase {
         */
        public function lastError();
 
-       /**
-        * mysql_fetch_field() wrapper
-        * Returns false if the field doesn't exist
-        *
-        * @param string $table Table name
-        * @param string $field Field name
-        *
-        * @return Field
-        */
-       public function fieldInfo( $table, $field );
-
        /**
         * Get the number of rows affected by the last write query
         * @see https://secure.php.net/mysql_affected_rows
@@ -508,12 +498,6 @@ interface IDatabase {
         */
        public function close();
 
-       /**
-        * @param string $error Fallback error message, used if none is given by DB
-        * @throws DBConnectionError
-        */
-       public function reportConnectionError( $error = 'Unknown error' );
-
        /**
         * Run an SQL query and return the result. Normally throws a DBQueryError
         * on failure. If errors are ignored, returns false instead.
@@ -542,19 +526,6 @@ interface IDatabase {
         */
        public function query( $sql, $fname = __METHOD__, $tempIgnore = false );
 
-       /**
-        * Report a query error. Log the error, and if neither the object ignore
-        * flag nor the $tempIgnore flag is set, throw a DBQueryError.
-        *
-        * @param string $error
-        * @param int $errno
-        * @param string $sql
-        * @param string $fname
-        * @param bool $tempIgnore
-        * @throws DBQueryError
-        */
-       public function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false );
-
        /**
         * Free a result object returned by query() or select(). It's usually not
         * necessary to call this, just use unset() or let the variable holding
@@ -903,16 +874,6 @@ interface IDatabase {
         */
        public function tableExists( $table, $fname = __METHOD__ );
 
-       /**
-        * Determines if a given index is unique
-        *
-        * @param string $table
-        * @param string $index
-        *
-        * @return bool
-        */
-       public function indexUnique( $table, $index );
-
        /**
         * INSERT wrapper, inserts an array into a table.
         *
@@ -1754,16 +1715,6 @@ interface IDatabase {
         */
        public function flushSnapshot( $fname = __METHOD__ );
 
-       /**
-        * List all tables on the database
-        *
-        * @param string $prefix Only show tables with this prefix, e.g. mw_
-        * @param string $fname Calling function name
-        * @throws DBError
-        * @return array
-        */
-       public function listTables( $prefix = null, $fname = __METHOD__ );
-
        /**
         * Convert a timestamp in one of the formats accepted by wfTimestamp()
         * to the format used for inserting into timestamp fields in this DBMS.
index d0c398e..18e3cbb 100644 (file)
@@ -275,6 +275,37 @@ interface IMaintainableDatabase extends IDatabase {
         * @since 1.29
         */
        public function unlockTables( $method );
+
+       /**
+        * List all tables on the database
+        *
+        * @param string $prefix Only show tables with this prefix, e.g. mw_
+        * @param string $fname Calling function name
+        * @throws DBError
+        * @return array
+        */
+       public function listTables( $prefix = null, $fname = __METHOD__ );
+
+       /**
+        * Determines if a given index is unique
+        *
+        * @param string $table
+        * @param string $index
+        *
+        * @return bool
+        */
+       public function indexUnique( $table, $index );
+
+       /**
+        * mysql_fetch_field() wrapper
+        * Returns false if the field doesn't exist
+        *
+        * @param string $table Table name
+        * @param string $field Field name
+        *
+        * @return Field
+        */
+       public function fieldInfo( $table, $field );
 }
 
 class_alias( IMaintainableDatabase::class, 'IMaintainableDatabase' );
index 6c94eb9..ff4b050 100644 (file)
@@ -80,6 +80,18 @@ class MaintainableDBConnRef extends DBConnRef implements IMaintainableDatabase {
        public function unlockTables( $method ) {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
+
+       public function indexUnique( $table, $index ) {
+               return $this->__call( __FUNCTION__, func_get_args() );
+       }
+
+       public function listTables( $prefix = null, $fname = __METHOD__ ) {
+               return $this->__call( __FUNCTION__, func_get_args() );
+       }
+
+       public function fieldInfo( $table, $field ) {
+               return $this->__call( __FUNCTION__, func_get_args() );
+       }
 }
 
 class_alias( MaintainableDBConnRef::class, 'MaintainableDBConnRef' );
index d6523a7..47d7533 100644 (file)
@@ -1871,7 +1871,9 @@ class User implements IDBAccessObject, UserIdentity {
                        $this->mHideName = $block->mHideName;
                        $this->mAllowUsertalk = !$block->prevents( 'editownusertalk' );
                } else {
+                       $this->mBlock = null;
                        $this->mBlockedby = '';
+                       $this->mBlockreason = '';
                        $this->mHideName = 0;
                        $this->mAllowUsertalk = false;
                }
index 56fe5b9..d447f91 100644 (file)
@@ -15,7 +15,7 @@
                // Parent
                mw.rcfilters.ui.MarkSeenButtonWidget.parent.call( this, $.extend( {
                        label: mw.message( 'rcfilters-watchlist-markseen-button' ).text(),
-                       icon: 'doubleCheck'
+                       icon: 'checkAll'
                }, config ) );
 
                this.controller = controller;
index c225ba5..ca83d66 100644 (file)
@@ -1142,4 +1142,55 @@ class UserTest extends MediaWikiTestCase {
                } catch ( InvalidArgumentException $ex ) {
                }
        }
+
+       /**
+        * @covers User::getBlockedStatus
+        * @covers User::getBlock
+        * @covers User::blockedBy
+        * @covers User::blockedFor
+        * @covers User::isHidden
+        * @covers User::isBlockedFrom
+        */
+       public function testBlockInstanceCache() {
+               // First, check the user isn't blocked
+               $user = $this->getMutableTestUser()->getUser();
+               $ut = Title::makeTitle( NS_USER_TALK, $user->getName() );
+               $this->assertNull( $user->getBlock( false ), 'sanity check' );
+               $this->assertSame( '', $user->blockedBy(), 'sanity check' );
+               $this->assertSame( '', $user->blockedFor(), 'sanity check' );
+               $this->assertFalse( (bool)$user->isHidden(), 'sanity check' );
+               $this->assertFalse( $user->isBlockedFrom( $ut ), 'sanity check' );
+
+               // Block the user
+               $blocker = $this->getTestSysop()->getUser();
+               $block = new Block( [
+                       'hideName' => true,
+                       'allowUsertalk' => false,
+                       'reason' => 'Because',
+               ] );
+               $block->setTarget( $user );
+               $block->setBlocker( $blocker );
+               $res = $block->insert();
+               $this->assertTrue( (bool)$res['id'], 'sanity check: Failed to insert block' );
+
+               // Clear cache and confirm it loaded the block properly
+               $user->clearInstanceCache();
+               $this->assertInstanceOf( Block::class, $user->getBlock( false ) );
+               $this->assertSame( $blocker->getName(), $user->blockedBy() );
+               $this->assertSame( 'Because', $user->blockedFor() );
+               $this->assertTrue( (bool)$user->isHidden() );
+               $this->assertTrue( $user->isBlockedFrom( $ut ) );
+
+               // Unblock
+               $block->delete();
+
+               // Clear cache and confirm it loaded the not-blocked properly
+               $user->clearInstanceCache();
+               $this->assertNull( $user->getBlock( false ) );
+               $this->assertSame( '', $user->blockedBy() );
+               $this->assertSame( '', $user->blockedFor() );
+               $this->assertFalse( (bool)$user->isHidden() );
+               $this->assertFalse( $user->isBlockedFrom( $ut ) );
+       }
+
 }