Merge "Remove classes and functions deprecated in MediaWiki 1.17"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 9 Jan 2014 21:11:51 +0000 (21:11 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 9 Jan 2014 21:11:51 +0000 (21:11 +0000)
1  2 
RELEASE-NOTES-1.23
includes/AutoLoader.php
includes/WebRequest.php
includes/api/ApiMain.php

diff --combined RELEASE-NOTES-1.23
@@@ -44,8 -44,6 +44,8 @@@ production
  * (bug 56033) Add content model to the page information.
  * Added Article::MissingArticleConditions hook to give extensions a chance to
    hide their (unrelated) log entries.
 +* Added LonelyPagesQuery hook to let extensions modify the query used to
 +  generate Special:LonelyPages.
  * Added $wgOpenSearchDefaultLimit defining the default number of entries to show
    on action=opensearch API call.
  * For namespaces with $wgNamespaceProtection (including the MediaWiki
    its #test method when strings are used in the browser map: version '1.10' is
    now correctly considered larger than '1.2'. Using numbers in the version map
    is not affected.
 +* All API modules now support an assert parameter, which can either be
 +  'user' or 'bot'. The API will throw an error if the user is not logged
 +  in (user) or does not have the 'bot' userright (bot). Based off of the
 +  AssertEdit extension by Steve Sanbeg.
 +* WikitextContent will now render redirects with the expected "redirect"
 +  header, rather than as an ordered list. Code calling Article::viewRedirect
 +  can probably be changed to no longer special-case redirects.
  
  === Bug fixes in 1.23 ===
  * (bug 41759) The "updated since last visit" markers (on history pages, recent
    the JavaScript evaluator were updated to support the new format. Plural rules
    for some languages have changed, most notably Russian. Affected software
    messages have been updated and marked for review at translatewiki.net.
 +* (bug 14323) Redirect pages, when viewed with redirect=no, no longer hide the
 +  remaining page content.
 +* (bug 23542) imagelinks now stores both the redirect and target (as
 +  templatelinks does).
  
  === Web API changes in 1.23 ===
  * (bug 54884) action=parse&prop=categories now indicates hidden and missing
  * ApiQueryBase::titlePartToKey allows an extra parameter that indicates the
    namespace in order to properly capitalize the title part.
  * (bug 57874) action=feedcontributions no longer has one item more than limit.
 +* All API modules now support an assert parameter. See the new features section
 +  for more details.
 +* Added prop=contributors to fetch the list of contributors to the page.
  
  === Languages updated in 1.23 ===
  
@@@ -159,8 -143,11 +159,11 @@@ changes to languages because of Bugzill
    SpecialPage::getPageTitle.
  
  ==== Removed classes ====
- * TitleDependency
- * TitleListDependency
+ * TitleDependency (unused)
+ * TitleListDependency (unused)
+ * WikiError (deprecated in 1.17)
+ * WikiXmlError (deprecated in 1.17)
+ * WikiErrorMsg (deprecated in 1.17)
  
  ==== Renamed classes ====
  * CdbReader_DBA to CdbReaderDBA
  * wikiStatsOutput to WikiStatsOutput
  
  ==== Removed methods ====
+ * ApiBase::getValidNamespaces() (deprecated in 1.17)
+ * ApiMain::setCachePrivate() (deprecated in 1.17)
+ * ApiMain::setVaryCookie (deprecated in 1.17)
+ * CategoryViewer::addSubcategory() (deprecated in 1.17)
  * EditPage::spamPage() (deprecated since 1.17)
  * Exif::getFormattedData() (deprecated in 1.18)
  * Exif::makeFormattedData() (deprecated in 1.18)
  * SpecialRecentChanges::feedSetup()
  * SpecialRevisionDelete::extractBitField() (deprecated in 1.22)
  * User::getPageRenderingHash() (deprecated in 1.17)
+ * WebRequest::getFileSize() (deprecated in 1.17)
+ * WebRequest::isPathInfoBad() (deprecated in 1.17)
  * WikiPage::quickEdit() (deprecated in 1.18)
  * WikiPage::useParserCache() (deprecated in 1.18)
  * WikiPage::viewUpdates() (deprecated in 1.18)
diff --combined includes/AutoLoader.php
@@@ -234,8 -234,6 +234,6 @@@ $wgAutoloadLocalClasses = array
        'WebRequestUpload' => 'includes/WebRequest.php',
        'WebResponse' => 'includes/WebResponse.php',
        'WikiCategoryPage' => 'includes/WikiCategoryPage.php',
-       'WikiError' => 'includes/WikiError.php',
-       'WikiErrorMsg' => 'includes/WikiError.php',
        'WikiExporter' => 'includes/Export.php',
        'WikiFilePage' => 'includes/WikiFilePage.php',
        'WikiImporter' => 'includes/Import.php',
        'WikiRevision' => 'includes/Import.php',
        'WikiMap' => 'includes/WikiMap.php',
        'WikiReference' => 'includes/WikiMap.php',
-       'WikiXmlError' => 'includes/WikiError.php',
        'Xml' => 'includes/Xml.php',
        'XmlDumpWriter' => 'includes/Export.php',
        'XmlJsCode' => 'includes/Xml.php',
        'ApiQueryCategoryInfo' => 'includes/api/ApiQueryCategoryInfo.php',
        'ApiQueryCategoryMembers' => 'includes/api/ApiQueryCategoryMembers.php',
        'ApiQueryContributions' => 'includes/api/ApiQueryUserContributions.php',
 +      'ApiQueryContributors' => 'includes/api/ApiQueryContributors.php',
        'ApiQueryDeletedrevs' => 'includes/api/ApiQueryDeletedrevs.php',
        'ApiQueryDisabled' => 'includes/api/ApiQueryDisabled.php',
        'ApiQueryDuplicateFiles' => 'includes/api/ApiQueryDuplicateFiles.php',
        'CSSJanus_Tokenizer' => 'includes/libs/CSSJanus.php',
        'CSSMin' => 'includes/libs/CSSMin.php',
        'GenericArrayObject' => 'includes/libs/GenericArrayObject.php',
 +      'HashRing' => 'includes/libs/HashRing.php',
        'HttpStatus' => 'includes/libs/HttpStatus.php',
        'IEContentAnalyzer' => 'includes/libs/IEContentAnalyzer.php',
        'IEUrlExtension' => 'includes/libs/IEUrlExtension.php',
 +      'MappedIterator' => 'includes/libs/MappedIterator.php',
        'JavaScriptMinifier' => 'includes/libs/JavaScriptMinifier.php',
        'JSCompilerContext' => 'includes/libs/jsminplus.php',
        'JSMinPlus' => 'includes/libs/jsminplus.php',
        'JSParser' => 'includes/libs/jsminplus.php',
        'JSToken' => 'includes/libs/jsminplus.php',
        'JSTokenizer' => 'includes/libs/jsminplus.php',
 +      'MultiHttpClient' => 'includes/libs/MultiHttpClient.php',
        'MWMessagePack' => 'includes/libs/MWMessagePack.php',
        'RunningStat' => 'includes/libs/RunningStat.php',
        'ScopedCallback' => 'includes/libs/ScopedCallback.php',
  
        # includes/profiler
        'Profiler' => 'includes/profiler/Profiler.php',
 +      'ProfilerMwprof' => 'includes/profiler/ProfilerMwprof.php',
        'ProfilerSimple' => 'includes/profiler/ProfilerSimple.php',
        'ProfilerSimpleText' => 'includes/profiler/ProfilerSimpleText.php',
        'ProfilerSimpleTrace' => 'includes/profiler/ProfilerSimpleTrace.php',
        'ConfEditorToken' => 'includes/utils/ConfEditor.php',
        'DoubleReplacer' => 'includes/utils/StringUtils.php',
        'ExplodeIterator' => 'includes/utils/StringUtils.php',
 -      'HashRing' => 'includes/utils/HashRing.php',
        'HashtableReplacer' => 'includes/utils/StringUtils.php',
        'IP' => 'includes/utils/IP.php',
        'MWCryptRand' => 'includes/utils/MWCryptRand.php',
        'MWFunction' => 'includes/utils/MWFunction.php',
 -      'MappedIterator' => 'includes/utils/MappedIterator.php',
        'RegexlikeReplacer' => 'includes/utils/StringUtils.php',
        'ReplacementArray' => 'includes/utils/StringUtils.php',
        'Replacer' => 'includes/utils/StringUtils.php',
@@@ -1160,6 -1154,9 +1157,6 @@@ class AutoLoader 
         * autoload - take a class name and attempt to load it
         *
         * @param string $className name of class we're looking for.
 -       * @return bool Returning false is important on failure as
 -       * it allows Zend to try and look in other registered autoloaders
 -       * as well.
         */
        static function autoload( $className ) {
                global $wgAutoloadClasses, $wgAutoloadLocalClasses,
                        }
  
                        # Give up
 -                      return false;
 +                      return;
 +              }
 +
 +              if ( substr( $filename, 0, 6 ) === 'alias:' ) {
 +                      // Supported alias formats:
 +                      // - No deprecation warning: alias:MyNewClassName
 +                      // - Deprecated in MediaWiki 1.1: alias:MyNewClassName?v=1.1
 +                      // - Deprecated in MyExtension 1.1: alias:MyNewClassName?c=MyExtension&v=1.1
 +                      $parts = explode( '?', substr( $filename, 6 ), 2 );
 +                      $newClassName = $parts[0];
 +
 +                      // If necessary, this will make a recursive call to this function to
 +                      // load the class using its actual, canonical name.
 +                      class_alias( $newClassName, $className );
 +
 +                      if ( isset( $parts[1] ) && function_exists( 'wfDeprecated' ) ) {
 +                              $info = wfCgiToArray( $parts[1] );
 +                              $function = "name $className for class $newClassName";
 +                              $version = isset( $info['v'] ) ? $info['v'] : false;
 +                              $component = isset( $info['c'] ) ? $info['c'] : false;
 +
 +                              // https://github.com/facebook/hhvm/issues/1018
 +                              $callerOffset = wfIsHHVM() ? 2 : 3;
 +                              wfDeprecated( $function, $version, $component, $callerOffset );
 +                      }
 +
 +                      return;
                }
  
                # Make an absolute path, this improves performance by avoiding some stat calls
                }
  
                require $filename;
 -
 -              return true;
        }
  
        /**
diff --combined includes/WebRequest.php
@@@ -795,12 -795,11 +795,12 @@@ class WebRequest 
         * defaults if not given. The limit must be positive and is capped at 5000.
         * Offset must be positive but is not capped.
         *
 -       * @param $deflimit Integer: limit to use if no input and the user hasn't set the option.
 +       * @param int $deflimit limit to use if no input and the user hasn't set the option.
         * @param string $optionname to specify an option other than rclimit to pull from.
 +       * @param int $hardlimit the maximum upper limit to allow, usually 5000
         * @return array first element is limit, second is offset
         */
 -      public function getLimitOffset( $deflimit = 50, $optionname = 'rclimit' ) {
 +      public function getLimitOffset( $deflimit = 50, $optionname = 'rclimit', $hardlimit = 5000 ) {
                global $wgUser;
  
                $limit = $this->getInt( 'limit', 0 );
                if ( $limit <= 0 ) {
                        $limit = $deflimit;
                }
 -              if ( $limit > 5000 ) {
 -                      $limit = 5000; # We have *some* limits...
 +              if ( $limit > $hardlimit ) {
 +                      $limit = $hardlimit; # We have *some* limits...
                }
  
                $offset = $this->getInt( 'offset', 0 );
                return $file->getTempName();
        }
  
-       /**
-        * Return the size of the upload, or 0.
-        *
-        * @deprecated since 1.17
-        * @param $key String:
-        * @return integer
-        */
-       public function getFileSize( $key ) {
-               wfDeprecated( __METHOD__, '1.17' );
-               $file = new WebRequestUpload( $this, $key );
-               return $file->getSize();
-       }
        /**
         * Return the upload error or 0
         *
@@@ -1036,35 -1022,6 +1023,6 @@@ HTML
                return true;
        }
  
-       /**
-        * Returns true if the PATH_INFO ends with an extension other than a script
-        * extension. This could confuse IE for scripts that send arbitrary data which
-        * is not HTML but may be detected as such.
-        *
-        * Various past attempts to use the URL to make this check have generally
-        * run up against the fact that CGI does not provide a standard method to
-        * determine the URL. PATH_INFO may be mangled (e.g. if cgi.fix_pathinfo=0),
-        * but only by prefixing it with the script name and maybe some other stuff,
-        * the extension is not mangled. So this should be a reasonably portable
-        * way to perform this security check.
-        *
-        * Also checks for anything that looks like a file extension at the end of
-        * QUERY_STRING, since IE 6 and earlier will use this to get the file type
-        * if there was no dot before the question mark (bug 28235).
-        *
-        * @deprecated Use checkUrlExtension().
-        *
-        * @param $extWhitelist array
-        *
-        * @return bool
-        */
-       public function isPathInfoBad( $extWhitelist = array() ) {
-               wfDeprecated( __METHOD__, '1.17' );
-               global $wgScriptExtension;
-               $extWhitelist[] = ltrim( $wgScriptExtension, '.' );
-               return IEUrlExtension::areServerVarsBad( $_SERVER, $extWhitelist );
-       }
        /**
         * Parse the Accept-Language header sent by the client into an array
         * @return array array( languageCode => q-value ) sorted by q-value in descending order then
@@@ -1463,14 -1420,6 +1421,6 @@@ class FauxRequest extends WebRequest 
                return $this->session;
        }
  
-       /**
-        * @param array $extWhitelist
-        * @return bool
-        */
-       public function isPathInfoBad( $extWhitelist = array() ) {
-               return false;
-       }
        /**
         * FauxRequests shouldn't depend on raw request data (but that could be implemented here)
         * @return String
diff --combined includes/api/ApiMain.php
@@@ -292,16 -292,6 +292,6 @@@ class ApiMain extends ApiBase 
                $this->mCacheMode = $mode;
        }
  
-       /**
-        * @deprecated since 1.17 Private caching is now the default, so there is usually no
-        * need to call this function. If there is a need, you can use
-        * $this->setCacheMode('private')
-        */
-       public function setCachePrivate() {
-               wfDeprecated( __METHOD__, '1.17' );
-               $this->setCacheMode( 'private' );
-       }
        /**
         * Set directives (key/value pairs) for the Cache-Control header.
         * Boolean values will be formatted as such, by including or omitting
                $this->mCacheControl = $directives + $this->mCacheControl;
        }
  
-       /**
-        * Make sure Vary: Cookie and friends are set. Use this when the output of a request
-        * may be cached for anons but may not be cached for logged-in users.
-        *
-        * WARNING: This function must be called CONSISTENTLY for a given URL. This means that a
-        * given URL must either always or never call this function; if it sometimes does and
-        * sometimes doesn't, stuff will break.
-        *
-        * @deprecated since 1.17 Use setCacheMode( 'anon-public-user-private' )
-        */
-       public function setVaryCookie() {
-               wfDeprecated( __METHOD__, '1.17' );
-               $this->setCacheMode( 'anon-public-user-private' );
-       }
        /**
         * Create an instance of an output formatter by its name
         *
                }
        }
  
 +      /**
 +       * Check asserts of the user's rights
 +       * @param $params array
 +       */
 +      protected function checkAsserts( $params ) {
 +              if ( isset( $params['assert'] ) ) {
 +                      $user = $this->getUser();
 +                      switch ( $params['assert'] ) {
 +                              case 'user':
 +                                      if ( $user->isAnon() ) {
 +                                              $this->dieUsage( 'Assertion that the user is logged in failed', 'assertuserfailed' );
 +                                      }
 +                                      break;
 +                              case 'bot':
 +                                      if ( !$user->isAllowed( 'bot' ) ) {
 +                                              $this->dieUsage( 'Assertion that the user has the bot right failed', 'assertbotfailed' );
 +                                      }
 +                                      break;
 +                      }
 +              }
 +      }
 +
        /**
         * Check POST for external response and setup result printer
         * @param $module ApiBase An Api module
                        $this->setupExternalResponse( $module, $params );
                }
  
 +              $this->checkAsserts( $params );
 +
                // Execute
                $module->profileIn();
                $module->execute();
                                ApiBase::PARAM_TYPE => 'integer',
                                ApiBase::PARAM_DFLT => 0
                        ),
 +                      'assert' => array(
 +                              ApiBase::PARAM_TYPE => array( 'user', 'bot' )
 +                      ),
                        'requestid' => null,
                        'servedby' => false,
                        'origin' => null,
                        ),
                        'smaxage' => 'Set the s-maxage header to this many seconds. Errors are never cached',
                        'maxage' => 'Set the max-age header to this many seconds. Errors are never cached',
 +                      'assert' => 'Verify the user is logged in if set to "user", or has the bot userright if "bot"',
                        'requestid' => 'Request ID to distinguish requests. This will just be output back to you',
                        'servedby' => 'Include the hostname that served the request in the ' .
                                'results. Unconditionally shown on error',
                        array( 'code' => 'unknown_action', 'info' => 'The API requires a valid action parameter' ),
                        array( 'code' => 'maxlag', 'info' => 'Waiting for host: x seconds lagged' ),
                        array( 'code' => 'maxlag', 'info' => 'Waiting for a database server: x seconds lagged' ),
 +                      array( 'code' => 'assertuserfailed', 'info' => 'Assertion that the user is logged in failed' ),
 +                      array( 'code' => 'assertbotfailed', 'info' => 'Assertion that the user has the bot right failed' ),
                ) );
        }