Merge "Create UserGetRightsRemove hook"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 30 Sep 2018 18:12:50 +0000 (18:12 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 30 Sep 2018 18:12:50 +0000 (18:12 +0000)
1  2 
RELEASE-NOTES-1.32
docs/hooks.txt
includes/user/User.php

diff --combined RELEASE-NOTES-1.32
@@@ -93,6 -93,9 +93,9 @@@ production
    This action should be considered deprecated and should not be used directly.
  * Extensions overriding ContentHandler::getUndoContent() will need to be
    updated for the changed method signature.
+ * Added a new hook, 'UserGetRightsRemove', which can be used to remove rights
+   from user. Unlike the 'UserGetRights' it will ensure that removed rights
+   will not be reinserted.
  
  === External library changes in 1.32 ===
  
  * Updated mediawiki/mediawiki-codesniffer from v20.0.0 to v21.0.0.
  * Updated composer/spdx-licenses from 1.3.0 to 1.4.0.
  * Updated jquery.i18n from 1.0.4 to 1.0.5.
 -* Updated wikimedia/timestamp from 1.0.0 to 2.0.0.
 +* Updated wikimedia/timestamp from 1.0.0 to 2.2.0.
  * Updated wikimedia/remex-html from 1.0.3 to 2.0.0.
  * Updated jquery from v3.2.1 to v3.3.1.
  
      content is not being preserved. 'fromsection-{slot}' and 'tosection-{slot}'
      instead expand the given text as if for a section edit. This effectively
      declines T183823 in favor of T185723.
 +* (T198214) The 'disabletidy' parameter to action=parse has been
 +  deprecated; untidy output will not be supported by future wikitext
 +  parsers.
  
  === Action API internal changes in 1.32 ===
  * Added 'ApiParseMakeOutputPage' hook.
  * Parameter names may no longer contain '{' or '}', as these are now used for
    templated parameters.
  * (T194950) Added 'ApiMaxLagInfo' hook.
 -* Added 'ApiParseMakeOutputPage' hook.
  * The following methods now take a RevisionRecord rather than a Revision. No
    external callers are known.
    * ApiFeedContributions::feedItemAuthor()
@@@ -318,13 -319,6 +321,13 @@@ because of Phabricator reports
    behaviour which has been deprecated since 1.24.
  * LBFactory, deprecated since 1.28, has been removed. Instead, use
    Wikimedia\Rdbms\LBFactory.
 +* The MimeMagic class, deprecated since 1.28 has been removed. Get a
 +  MimeAnalyzer instance from MediaWikiServices instead.
 +* The '--tidy' option to maintenance/parse.php has been removed.  Tidying
 +  the output is now the default.  Use '--no-tidy' to bypass the tidy
 +  phase.
 +* The global function wfErrorLog, deprecated since 1.25, has now been removed.
 +  Use MWLoggerLegacyLogger::emit or UDPTransport.
  
  === Deprecations in 1.32 ===
  * HTMLForm::setSubmitProgressive() is deprecated. No need to call it. Submit
  * QuickTemplate::msgHtml() and BaseTemplate::msgHtml() have been deprecated
    as they promote bad practises. I18n messages should always be properly
    escaped.
 +* Skin::getDynamicStylesheetQuery() has been deprecated. It always
 +  returns action=raw&ctype=text/css which callers should use directly.
 +* Class LegacyFormatter is deprecated.
  
  === Other changes in 1.32 ===
  * (T198811) The following tables have had their UNIQUE indexes turned into
diff --combined docs/hooks.txt
@@@ -2353,7 -2353,7 +2353,7 @@@ $title: title of the message (string
  $code: code (string) denoting the language to try.
  
  'MimeMagicGuessFromContent': Allows MW extensions guess the MIME by content.
 -$mimeMagic: Instance of MimeMagic.
 +$mimeMagic: Instance of MimeAnalyzer.
  &$head: First 1024 bytes of the file in a string (in - Do not alter!).
  &$tail: More or equal than last 65558 bytes of the file in a string
    (in - Do not alter!).
@@@ -2362,7 -2362,7 +2362,7 @@@ $file: File path
  
  'MimeMagicImproveFromExtension': Allows MW extensions to further improve the
  MIME type detected by considering the file extension.
 -$mimeMagic: Instance of MimeMagic.
 +$mimeMagic: Instance of MimeAnalyzer.
  $ext: File extension.
  &$mime: MIME type (in/out).
  
  and the list mapping MIME types to file extensions.
  As an extension author, you are encouraged to submit patches to MediaWiki's
  core to add new MIME types to mime.types.
 -$mimeMagic: Instance of MimeMagic.
 +$mimeMagic: Instance of MimeAnalyzer.
    Use $mimeMagic->addExtraInfo( $stringOfInfo );
    for adding new MIME info to the list.
    Use $mimeMagic->addExtraTypes( $stringOfTypes );
@@@ -3783,6 -3783,13 +3783,13 @@@ $context: IContextSource objec
  $user: User to get rights for
  &$rights: Current rights
  
+ 'UserGetRightsRemove': Called in User::getRights(). This hook override
+ the UserGetRights hook. It can be used to remove rights from user
+ and ensure that will not be reinserted by the other hook callbacks
+ therefore this hook should not be used to add any rights, use UserGetRights instead.
+ $user: User to get rights for
+ &$rights: Current rights
  'UserGroupsChanged': Called after user groups are changed.
  $user: User whose groups changed
  $added: Groups added
diff --combined includes/user/User.php
@@@ -1051,7 -1051,7 +1051,7 @@@ class User implements IDBAccessObject, 
                // Certain names may be reserved for batch processes.
                foreach ( $reservedUsernames as $reserved ) {
                        if ( substr( $reserved, 0, 4 ) == 'msg:' ) {
 -                              $reserved = wfMessage( substr( $reserved, 4 ) )->inContentLanguage()->text();
 +                              $reserved = wfMessage( substr( $reserved, 4 ) )->inContentLanguage()->plain();
                        }
                        if ( $reserved == $name ) {
                                return false;
                                }
                        }
  
+                       Hooks::run( 'UserGetRightsRemove', [ $this, &$this->mRights ] );
                        // Force reindexation of rights when a hook has unset one of them
                        $this->mRights = array_values( array_unique( $this->mRights ) );
  
                                        'user',
                                        'user_id',
                                        [ 'user_name' => $this->mName ],
 -                                      __METHOD__,
 +                                      $fname,
                                        [ 'LOCK IN SHARE MODE' ]
                                );
                                $loaded = false;
                                        }
                                }
                                if ( !$loaded ) {
 -                                      throw new MWException( __METHOD__ . ": hit a key conflict attempting " .
 +                                      throw new MWException( $fname . ": hit a key conflict attempting " .
                                                "to insert user '{$this->mName}' row, but it was not present in select!" );
                                }
                                return Status::newFatal( 'userexists' );