Merge "ApiQueryLogEvents: Add IGNORE INDEX to avoid MariaDB optimizer bug"
[lhc/web/wiklou.git] / includes / Block.php
index 1a54394..6abc83a 100644 (file)
@@ -121,6 +121,9 @@ class Block {
         *                          created by MediaWiki rather than being stored
         *                          in the database. Value is a string to return
         *                          from self::getSystemBlockType().
+        *     sitewide bool        Disallow editing all pages and all contribution
+        *                          actions, except those specifically allowed by
+        *                          other block flags
         *
         * @since 1.26 accepts $options array instead of individual parameters; order
         * of parameters above reflects the original order
@@ -1912,18 +1915,18 @@ class Block {
         * they can never edit it. (Ideally the flag would be stored as
         * null in these cases, but the database field isn't nullable.)
         *
+        * This method does not validate that the passed in talk page belongs to the
+        * block target since the target (an IP) might not be the same as the user's
+        * talk page (if they are logged in).
+        *
         * @since 1.33
         * @param Title|null $usertalk The user's user talk page. If null,
         *  and if the target is a User, the target's userpage is used
         * @return bool The user can edit their talk page
         */
        public function appliesToUsertalk( Title $usertalk = null ) {
-               $target = $this->target;
-               $targetIsUser = $target instanceof User;
-               $targetName = $targetIsUser ? $target->getName() : $target;
-
                if ( !$usertalk ) {
-                       if ( $targetIsUser ) {
+                       if ( $this->target instanceof User ) {
                                $usertalk = $this->target->getTalkPage();
                        } else {
                                throw new InvalidArgumentException(
@@ -1938,28 +1941,6 @@ class Block {
                        );
                }
 
-               switch ( $this->type ) {
-                       case self::TYPE_USER:
-                       case self::TYPE_IP:
-                               if ( $usertalk->getText() !== $targetName ) {
-                                       throw new InvalidArgumentException(
-                                               '$usertalk must be a talk page for the block target'
-                                       );
-                               }
-                               break;
-                       case self::TYPE_RANGE:
-                               if ( !IP::isInRange( $usertalk->getText(), $target ) ) {
-                                       throw new InvalidArgumentException(
-                                               '$usertalk must be a talk page for an IP within the block target range'
-                                       );
-                               }
-                               break;
-                       default:
-                               throw new LogicException(
-                                       'Cannot determine validity of $usertalk for this type of block'
-                               );
-               }
-
                if ( !$this->isSitewide() ) {
                        if ( $this->appliesToPage( $usertalk->getArticleID() ) ) {
                                return true;