Merge "Move cookie-blocking methods to BlockManager"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 11 Jun 2019 15:16:00 +0000 (15:16 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 11 Jun 2019 15:16:00 +0000 (15:16 +0000)
1  2 
RELEASE-NOTES-1.34
includes/EditPage.php
includes/user/User.php

diff --combined RELEASE-NOTES-1.34
@@@ -42,13 -42,6 +42,13 @@@ For notes on 1.33.x and older releases
    variable $wgCdnMaxageLagged. The previous configuration variable names are
    deprecated, but will be used as the fall back if they are still set.
    Note that wgSquidPurgeUseHostHeader has not been renamed, as it is deprecated.
 +* (T27707) File type checks for image uploads have been relaxed to allow files
 +  containing some HTML markup in metadata. As a result, the $wgAllowTitlesInSVG
 +  setting is no longer applied and is now always true. Note that MSIE 7 may
 +  still be able to misinterpret certain malformed PNG files as HTML.
 +* Introduced $wgVerifyMimeTypeIE to allow disabling the MSIE 6/7 file type
 +  detection heuristic on upload, which is more conservative than the checks
 +  that were changed above.
  * …
  
  ==== Removed configuration ====
@@@ -200,8 -193,6 +200,8 @@@ because of Phabricator reports
    directly.
  * HTMLForm::getErrors(), deprecated in 1.28, has been removed. Use
    getErrorsOrWarnings() instead.
 +* SpecialPage::getTitle(), deprecated in 1.23, has been removed. Use
 +  SpecialPage::getPageTitle() instead.
  * …
  
  === Deprecations in 1.34 ===
  * (T62260) Hard deprecate Language::getExtraUserToggles() method.
  * Language::viewPrevNext function is deprecated, use
    PrevNextNavigationRenderer::buildPrevNextNavigation instead
+ * User::trackBlockWithCookie and DatabaseBlock::clearCookie are deprecated. Use
+   BlockManager::trackBlockWithCookie and BlockManager::clearCookie instead.
+ * DatabaseBlock::setCookie, DatabaseBlock::getCookieValue,
+   DatabaseBlock::getIdFromCookieValue and AbstractBlock::shouldTrackWithCookie
+   are moved to internal helper methods for BlockManager::trackBlockWithCookie.
  
  === Other changes in 1.34 ===
  * …
diff --combined includes/EditPage.php
@@@ -622,7 -622,8 +622,8 @@@ class EditPage 
  
                        if ( $this->context->getUser()->getBlock() ) {
                                // track block with a cookie if it doesn't exists already
-                               $this->context->getUser()->trackBlockWithCookie();
+                               MediaWikiServices::getInstance()->getBlockManager()
+                                       ->trackBlockWithCookie( $this->context->getUser() );
  
                                // Auto-block user's IP if the account was "hard" blocked
                                if ( !wfReadOnly() ) {
@@@ -2591,7 -2592,7 +2592,7 @@@ ERROR
                        }
                } elseif ( $namespace == NS_FILE ) {
                        # Show a hint to shared repo
 -                      $file = wfFindFile( $this->mTitle );
 +                      $file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $this->mTitle );
                        if ( $file && !$file->isLocal() ) {
                                $descUrl = $file->getDescriptionUrl();
                                # there must be a description url to show a hint to shared repo
diff --combined includes/user/User.php
@@@ -1363,7 -1363,7 +1363,7 @@@ class User implements IDBAccessObject, 
                                // If this user is autoblocked, set a cookie to track the block. This has to be done on
                                // every session load, because an autoblocked editor might not edit again from the same
                                // IP address after being blocked.
-                               $this->trackBlockWithCookie();
+                               MediaWikiServices::getInstance()->getBlockManager()->trackBlockWithCookie( $this );
                        }
  
                        // Other code expects these to be set in the session, so set them.
  
        /**
         * Set the 'BlockID' cookie depending on block type and user authentication status.
+        *
+        * @deprecated since 1.34 Use BlockManager::trackBlockWithCookie instead
         */
        public function trackBlockWithCookie() {
-               $block = $this->getBlock();
-               if ( $block && $this->getRequest()->getCookie( 'BlockID' ) === null
-                       && $block->shouldTrackWithCookie( $this->isAnon() )
-               ) {
-                       $block->setCookie( $this->getRequest()->response() );
-               }
+               MediaWikiServices::getInstance()->getBlockManager()->trackBlockWithCookie( $this );
        }
  
        /**
                $dbw->insert( 'user_newtalk',
                        [ $field => $id, 'user_last_timestamp' => $dbw->timestampOrNull( $ts ) ],
                        __METHOD__,
 -                      'IGNORE' );
 +                      [ 'IGNORE' ] );
                if ( $dbw->affectedRows() ) {
                        wfDebug( __METHOD__ . ": set on ($field, $id)\n" );
                        return true;