Bug 35646 - ApiBlockTest::testMakeNormalBlock() broken
[lhc/web/wiklou.git] / includes / api / ApiMain.php
index 880d884..8f5cfca 100644 (file)
  * @defgroup API API
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       // Eclipse helper - will be ignored in production
-       require_once( 'ApiBase.php' );
-}
-
 /**
  * This is the main API class, used for both external and internal processing.
  * When executed, it will create the requested formatter object,
@@ -132,7 +127,7 @@ class ApiMain extends ApiBase {
        private $mPrinter;
 
        private $mModules, $mModuleNames, $mFormats, $mFormatNames;
-       private $mResult, $mAction, $mShowVersions, $mEnableWrite/*, $mRequest*/;
+       private $mResult, $mAction, $mShowVersions, $mEnableWrite;
        private $mInternalMode, $mSquidMaxage, $mModule;
 
        private $mCacheMode = 'private';
@@ -291,6 +286,7 @@ class ApiMain extends ApiBase {
         * $this->setCacheMode('private')
         */
        public function setCachePrivate() {
+               wfDeprecated( __METHOD__, '1.17' );
                $this->setCacheMode( 'private' );
        }
 
@@ -319,6 +315,7 @@ class ApiMain extends ApiBase {
         * @deprecated since 1.17 Use setCacheMode( 'anon-public-user-private' )
         */
        public function setVaryCookie() {
+               wfDeprecated( __METHOD__, '1.17' );
                $this->setCacheMode( 'anon-public-user-private' );
        }
 
@@ -404,7 +401,7 @@ class ApiMain extends ApiBase {
        }
 
        protected function sendCacheHeaders() {
-               global $wgUseXVO, $wgOut, $wgVaryOnXFP;
+               global $wgUseXVO, $wgVaryOnXFP;
                $response = $this->getRequest()->response();
 
                if ( $this->mCacheMode == 'private' ) {
@@ -416,11 +413,12 @@ class ApiMain extends ApiBase {
                        $xfp = $wgVaryOnXFP ? ', X-Forwarded-Proto' : '';
                        $response->header( 'Vary: Accept-Encoding, Cookie' . $xfp );
                        if ( $wgUseXVO ) {
+                               $out = $this->getOutput();
                                if ( $wgVaryOnXFP ) {
-                                       $wgOut->addVaryHeader( 'X-Forwarded-Proto' );
+                                       $out->addVaryHeader( 'X-Forwarded-Proto' );
                                }
-                               $response->header( $wgOut->getXVO() );
-                               if ( $wgOut->haveCacheVaryCookies() ) {
+                               $response->header( $out->getXVO() );
+                               if ( $out->haveCacheVaryCookies() ) {
                                        // Logged in, mark this request private
                                        $response->header( 'Cache-Control: private' );
                                        return;
@@ -597,11 +595,11 @@ class ApiMain extends ApiBase {
 
                // Die if token required, but not provided (unless there is a gettoken parameter)
                $salt = $module->getTokenSalt();
-               if ( $salt !== false && !isset( $moduleParams['gettoken'] ) ) {
+               if ( $salt !== false && !$moduleParams['gettoken'] ) {
                        if ( !isset( $moduleParams['token'] ) ) {
                                $this->dieUsageMsg( array( 'missingparam', 'token' ) );
                        } else {
-                               if ( !$this->getUser()->matchEditToken( $moduleParams['token'], $salt, $this->getRequest() ) ) {
+                               if ( !$this->getUser()->matchEditToken( $moduleParams['token'], $salt ) ) {
                                        $this->dieUsageMsg( 'sessionfailure' );
                                }
                        }
@@ -794,7 +792,7 @@ class ApiMain extends ApiBase {
                                'wait until the replication lag is less than the specified value.',
                                'In case of a replag error, a HTTP 503 error is returned, with the message like',
                                '"Waiting for $host: $lag seconds lagged\n".',
-                               'See http://www.mediawiki.org/wiki/Manual:Maxlag_parameter for more information',
+                               'See https://www.mediawiki.org/wiki/Manual:Maxlag_parameter for more information',
                        ),
                        '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',
@@ -816,8 +814,8 @@ class ApiMain extends ApiBase {
                        '**                                                                                                      **',
                        '**                      This is an auto-generated MediaWiki API documentation page                      **',
                        '**                                                                                                      **',
-                       '**                                    Documentation and Examples:                                       **',
-                       '**                                 http://www.mediawiki.org/wiki/API                                    **',
+                       '**                                     Documentation and Examples:                                      **',
+                       '**                                  https://www.mediawiki.org/wiki/API                                  **',
                        '**                                                                                                      **',
                        '**********************************************************************************************************',
                        '',
@@ -832,13 +830,13 @@ class ApiMain extends ApiBase {
                        '                       In the case of an invalid action being passed, these will have a value',
                        '                       of "unknown_action"',
                        '',
-                       '                       For more information see http://www.mediawiki.org/wiki/API:Errors_and_warnings',
+                       '                       For more information see https://www.mediawiki.org/wiki/API:Errors_and_warnings',
                        '',
-                       'Documentation:         http://www.mediawiki.org/wiki/API:Main_page',
-                       'FAQ                    http://www.mediawiki.org/wiki/API:FAQ',
-                       'Mailing list:          http://lists.wikimedia.org/mailman/listinfo/mediawiki-api',
-                       'Api Announcements:     http://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce',
-                       'Bugs & Requests:       http://bugzilla.wikimedia.org/buglist.cgi?component=API&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&order=bugs.delta_ts',
+                       'Documentation:         https://www.mediawiki.org/wiki/API:Main_page',
+                       'FAQ                    https://www.mediawiki.org/wiki/API:FAQ',
+                       'Mailing list:          https://lists.wikimedia.org/mailman/listinfo/mediawiki-api',
+                       'Api Announcements:     https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce',
+                       'Bugs & Requests:       https://bugzilla.wikimedia.org/buglist.cgi?component=API&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&order=bugs.delta_ts',
                        '',
                        '',
                        '',
@@ -874,7 +872,7 @@ class ApiMain extends ApiBase {
                        '    Yuri Astrakhan <Firstname><Lastname>@gmail.com (creator, lead developer Sep 2006-Sep 2007)',
                        '',
                        'Please send your comments, suggestions and questions to mediawiki-api@lists.wikimedia.org',
-                       'or file a bug report at http://bugzilla.wikimedia.org/'
+                       'or file a bug report at https://bugzilla.wikimedia.org/'
                );
        }
 
@@ -1001,7 +999,7 @@ class ApiMain extends ApiBase {
         */
        public function getVersion() {
                $vers = array();
-               $vers[] = 'MediaWiki: ' . SpecialVersion::getVersion() . "\n    http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/";
+               $vers[] = 'MediaWiki: ' . SpecialVersion::getVersion() . "\n    https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/";
                $vers[] = __CLASS__ . ': $Id$';
                $vers[] = ApiBase::getBaseVersion();
                $vers[] = ApiFormatBase::getBaseVersion();
@@ -1057,7 +1055,7 @@ class ApiMain extends ApiBase {
  *
  * @ingroup API
  */
-class UsageException extends Exception {
+class UsageException extends MWException {
 
        private $mCodestr;
        private $mExtraData;