Merge "[search] Remove more dead code"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 8 Nov 2016 18:19:13 +0000 (18:19 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 8 Nov 2016 18:19:13 +0000 (18:19 +0000)
13 files changed:
autoload.php
docs/hooks.txt
includes/OutputPage.php
includes/PHPVersionCheck.php
includes/actions/MarkpatrolledAction.php
includes/diff/DifferenceEngine.php
includes/page/Article.php
includes/specialpage/LoginSignupSpecialPage.php
includes/specials/SpecialPasswordReset.php
languages/i18n/en.json
languages/i18n/qqq.json
resources/src/startup.js
tests/qunit/suites/resources/startup.test.js

index bbf4bd0..30ef985 100644 (file)
@@ -1010,6 +1010,7 @@ $wgAutoloadLocalClasses = [
        'OrphanStats' => __DIR__ . '/maintenance/storage/orphanStats.php',
        'Orphans' => __DIR__ . '/maintenance/orphans.php',
        'OutputPage' => __DIR__ . '/includes/OutputPage.php',
+       'PHPVersionCheck' => __DIR__ . '/includes/PHPVersionCheck.php',
        'PNGHandler' => __DIR__ . '/includes/media/PNG.php',
        'PNGMetadataExtractor' => __DIR__ . '/includes/media/PNGMetadataExtractor.php',
        'PPCustomFrame_DOM' => __DIR__ . '/includes/parser/Preprocessor_DOM.php',
index 906623f..4543077 100644 (file)
@@ -1200,7 +1200,6 @@ wrapped in a span element which has class="patrollink".
 $differenceEngine: DifferenceEngine object
 &$markAsPatrolledLink: The "mark as patrolled" link HTML (string)
 $rcid: Recent change ID (rc_id) for this change (int)
-$token: Patrol token; $rcid is used in generating this variable
 
 'DifferenceEngineMarkPatrolledRCID': Allows extensions to possibly change the rcid parameter.
 For example the rcid might be set to zero due to the user being the same as the
@@ -2487,12 +2486,24 @@ cache or return false to not use it.
 &$parser: Parser object
 &$varCache: variable cache (array)
 
-'ParserLimitReport': DEPRECATED! Use ParserLimitReportPrepare instead.
+'ParserLimitReport': DEPRECATED! Use ParserLimitReportPrepare and
+ParserLimitReportFormat instead.
 Called at the end of Parser:parse() when the parser will
 include comments about size of the text parsed.
 $parser: Parser object
 &$limitReport: text that will be included (without comment tags)
 
+'ParserLimitReportFormat': Called for each row in the parser limit report that
+needs formatting. If nothing handles this hook, the default is to use "$key" to
+get the label, and "$key-value" or "$key-value-text"/"$key-value-html" to
+format the value.
+$key: Key for the limit report item (string)
+&$value: Value of the limit report item
+&$report: String onto which to append the data
+$isHTML: If true, $report is an HTML table with two columns; if false, it's
+  text intended for display in a monospaced font.
+$localize: If false, $report should be output in English.
+
 'ParserLimitReportPrepare': Called at the end of Parser:parse() when the parser
 will include comments about size of the text parsed. Hooks should use
 $output->setLimitReportData() to populate data. Functions for this hook should
@@ -2521,10 +2532,6 @@ $showEditLinks: boolean describing whether this section has an edit link
 &$globals: Array with all the globals which should be set for parser tests.
   The arrays keys serve as the globals names, its values are the globals values.
 
-'ParserTestParser': Called when creating a new instance of Parser in
-tests/parser/parserTest.inc.
-&$parser: Parser object created
-
 'ParserTestTables': Alter the list of tables to duplicate when parser tests are
 run. Use when page save hooks require the presence of custom tables to ensure
 that tests continue to run properly.
index 07b7029..12df3a5 100644 (file)
@@ -1214,8 +1214,8 @@ class OutputPage extends ContextSource {
        /**
         * Add new language links
         *
-        * @param array $newLinkArray Associative array mapping language code to the page
-        *                      name
+        * @param string[] $newLinkArray Array of interwiki-prefixed (non DB key) titles
+        *                               (e.g. 'fr:Test page')
         */
        public function addLanguageLinks( array $newLinkArray ) {
                $this->mLanguageLinks += $newLinkArray;
@@ -1224,8 +1224,8 @@ class OutputPage extends ContextSource {
        /**
         * Reset the language links and add new language links
         *
-        * @param array $newLinkArray Associative array mapping language code to the page
-        *                      name
+        * @param string[] $newLinkArray Array of interwiki-prefixed (non DB key) titles
+        *                               (e.g. 'fr:Test page')
         */
        public function setLanguageLinks( array $newLinkArray ) {
                $this->mLanguageLinks = $newLinkArray;
@@ -1234,7 +1234,7 @@ class OutputPage extends ContextSource {
        /**
         * Get the list of language links
         *
-        * @return array Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page')
+        * @return string[] Array of interwiki-prefixed (non DB key) titles (e.g. 'fr:Test page')
         */
        public function getLanguageLinks() {
                return $this->mLanguageLinks;
index 656ba43..e6e96c7 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+// @codingStandardsIgnoreFile Generic.Arrays.DisallowLongArraySyntax
+// @codingStandardsIgnoreFile Generic.Files.LineLength
+// @codingStandardsIgnoreFile MediaWiki.Usage.DirUsage.FunctionFound
 /**
  * Check PHP Version, as well as for composer dependencies in entry points,
  * and display something vaguely comprehensible in the event of a totally
  *
  * @file
  */
-
-/**
- * Check php version and that external dependencies are installed, and
- * display an informative error if either condition is not satisfied.
- *
- * @note Since we can't rely on anything, the minimum PHP versions and MW current
- * version are hardcoded here
- */
-function wfEntryPointCheck( $entryPoint ) {
-       $mwVersion = '1.29';
-       $minimumVersionPHP = '5.5.9';
-       $phpVersion = PHP_VERSION;
-
-       if ( !function_exists( 'version_compare' )
-               || version_compare( $phpVersion, $minimumVersionPHP ) < 0
-       ) {
-               wfPHPVersionError( $entryPoint, $mwVersion, $minimumVersionPHP, $phpVersion );
-       }
-
-       // @codingStandardsIgnoreStart MediaWiki.Usage.DirUsage.FunctionFound
-       if ( !file_exists( dirname( __FILE__ ) . '/../vendor/autoload.php' ) ) {
-               // @codingStandardsIgnoreEnd
-               wfMissingVendorError( $entryPoint, $mwVersion );
-       }
-
-       // List of functions and their associated PHP extension to check for
-       // @codingStandardsIgnoreStart Generic.Arrays.DisallowLongArraySyntax
-       $extensions = array(
+class PHPVersionCheck {
+       /* @var string The number of the MediaWiki version used */
+       var $mwVersion = '1.29';
+       /* @var string The minimum php version for MediaWiki to run */
+       var $minimumVersionPHP = '5.5.9';
+       var $functionsExtensionsMapping = array(
                'mb_substr'   => 'mbstring',
                'utf8_encode' => 'xml',
                'ctype_digit' => 'ctype',
                'json_decode' => 'json',
                'iconv'       => 'iconv',
        );
-       // List of extensions we're missing
-       $missingExtensions = array();
-       // @codingStandardsIgnoreEnd
 
-       foreach ( $extensions as $function => $extension ) {
-               if ( !function_exists( $function ) ) {
-                       $missingExtensions[] = $extension;
+       /**
+        * @var string Which entry point we are protecting. One of:
+        *   - index.php
+        *   - load.php
+        *   - api.php
+        *   - mw-config/index.php
+        *   - cli
+        */
+       var $entryPoint = null;
+
+       /**
+        * @param string $entryPoint Which entry point we are protecting. One of:
+        *   - index.php
+        *   - load.php
+        *   - api.php
+        *   - mw-config/index.php
+        *   - cli
+        * @return $this
+        */
+       function setEntryPoint( $entryPoint ) {
+               $this->entryPoint = $entryPoint;
+       }
+
+       /**
+        * Returns the version of the installed php implementation.
+        *
+        * @return string
+        */
+       function getPHPImplVersion() {
+               return PHP_VERSION;
+       }
+
+       /**
+        * Displays an error, if the installed php version does not meet the minimum requirement.
+        *
+        * @return $this
+        */
+       function checkRequiredPHPVersion() {
+               if ( !function_exists( 'version_compare' )
+                    || version_compare( $this->getPHPImplVersion(), $this->minimumVersionPHP ) < 0
+               ) {
+                       $shortText = "MediaWiki $this->mwVersion requires at least PHP version"
+                                    . " $this->minimumVersionPHP, you are using PHP {$this->getPHPImplVersion()}.";
+
+                       $longText = "Error: You might be using on older PHP version. \n"
+                                   . "MediaWiki $this->mwVersion needs PHP $this->minimumVersionPHP or higher.\n\n"
+                                   . "Check if you have a newer php executable with a different name, "
+                                   . "such as php5.\n\n";
+
+                       $longHtml = <<<HTML
+                       Please consider <a href="http://www.php.net/downloads.php">upgrading your copy of PHP</a>.
+                       PHP versions less than 5.5.0 are no longer supported by the PHP Group and will not receive
+                       security or bugfix updates.
+               </p>
+               <p>
+                       If for some reason you are unable to upgrade your PHP version, you will need to
+                       <a href="https://www.mediawiki.org/wiki/Download">download</a> an older version
+                       of MediaWiki from our website.  See our
+                       <a href="https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
+                       for details of which versions are compatible with prior versions of PHP.
+HTML;
+                       $this->triggerError( 'Supported PHP versions', $shortText, $longText, $longHtml );
                }
        }
 
-       if ( $missingExtensions ) {
-               wfMissingExtensions( $entryPoint, $mwVersion, $missingExtensions );
+       /**
+        * Displays an error, if the vendor/autoload.php file could not be found.
+        *
+        * @return $this
+        */
+       function checkVendorExistence() {
+               if ( !file_exists( dirname( __FILE__ ) . '/../vendor/autoload.php' ) ) {
+                       $shortText = "Installing some external dependencies (e.g. via composer) is required.";
+
+                       $longText = "Error: You are missing some external dependencies. \n"
+                                   . "MediaWiki now also has some external dependencies that need to be installed\n"
+                                   . "via composer or from a separate git repo. Please see\n"
+                                   . "https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n"
+                                   . "for help on installing the required components.";
+
+                       $longHtml = <<<HTML
+               MediaWiki now also has some external dependencies that need to be installed via
+               composer or from a separate git repo. Please see
+               <a href="https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries">mediawiki.org</a>
+               for help on installing the required components.
+HTML;
+
+                       $this->triggerError( 'External dependencies', $shortText, $longText, $longHtml );
+               }
        }
-}
 
-/**
- * Display something vaguely comprehensible in the event of a totally unrecoverable error.
- * Does not assume access to *anything*; no globals, no autoloader, no database, no localisation.
- * Safe for PHP4 (and putting this here means that WebStart.php and GlobalSettings.php
- * no longer need to be).
- *
- * Calling this function kills execution immediately.
- *
- * @param string $type Which entry point we are protecting. One of:
- *   - index.php
- *   - load.php
- *   - api.php
- *   - mw-config/index.php
- *   - cli
- * @param string $mwVersion The number of the MediaWiki version used
- * @param string $title HTML code to be put within an <h2> tag
- * @param string $shortText
- * @param string $longText
- * @param string $longHtml
- */
-function wfGenericError( $type, $mwVersion, $title, $shortText, $longText, $longHtml ) {
-       $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
+       /**
+        * Displays an error, if a PHP extension does not exist.
+        *
+        * @return $this
+        */
+       function checkExtensionExistence() {
+               $missingExtensions = array();
+               foreach ( $this->functionsExtensionsMapping as $function => $extension ) {
+                       if ( !function_exists( $function ) ) {
+                               $missingExtensions[] = $extension;
+                       }
+               }
+
+               if ( $missingExtensions ) {
+                       $shortText = "Installing some PHP extensions is required.";
+
+                       $missingExtText = '';
+                       $missingExtHtml = '';
+                       $baseUrl = 'https://secure.php.net';
+                       foreach ( $missingExtensions as $ext ) {
+                               $missingExtText .= " * $ext <$baseUrl/$ext>\n";
+                               $missingExtHtml .= "<li><b>$ext</b> "
+                                                  . "(<a href=\"$baseUrl/$ext\">more information</a>)</li>";
+                       }
+
+                       $cliText = "Error: Missing one or more required components of PHP.\n"
+                                  . "You are missing a required extension to PHP that MediaWiki needs.\n"
+                                  . "Please install:\n" . $missingExtText;
+
+                       $longHtml = <<<HTML
+               You are missing a required extension to PHP that MediaWiki
+               requires to run. Please install:
+               <ul>
+               $missingExtHtml
+               </ul>
+HTML;
+
+                       $this->triggerError( 'Required components', $shortText, $cliText, $longHtml );
+               }
+       }
+
+       /**
+        * Output headers that prevents error pages to be cached.
+        */
+       function outputHTMLHeader() {
+               $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
 
-       if ( $type == 'cli' ) {
-               $finalOutput = $longText;
-       } else {
                header( "$protocol 500 MediaWiki configuration Error" );
                // Don't cache error pages!  They cause no end of trouble...
                header( 'Cache-control: none' );
                header( 'Pragma: no-cache' );
+       }
 
-               if ( $type == 'index.php' || $type == 'mw-config/index.php' ) {
-                       $pathinfo = pathinfo( $_SERVER['SCRIPT_NAME'] );
-                       if ( $type == 'mw-config/index.php' ) {
-                               $dirname = dirname( $pathinfo['dirname'] );
-                       } else {
-                               $dirname = $pathinfo['dirname'];
-                       }
-                       $encLogo = htmlspecialchars(
-                               str_replace( '//', '/', $dirname . '/' ) .
-                               'resources/assets/mediawiki.png'
-                       );
-                       $shortHtml = htmlspecialchars( $shortText );
+       /**
+        * Returns an error page, which is suitable for output to the end user via a web browser.
+        *
+        * @param $title
+        * @param $longHtml
+        * @param $shortText
+        * @return string
+        */
+       function getIndexErrorOutput( $title, $longHtml, $shortText ) {
+               $pathinfo = pathinfo( $_SERVER['SCRIPT_NAME'] );
+               if ( $this->entryPoint == 'mw-config/index.php' ) {
+                       $dirname = dirname( $pathinfo['dirname'] );
+               } else {
+                       $dirname = $pathinfo['dirname'];
+               }
+               $encLogo =
+                       htmlspecialchars( str_replace( '//', '/', $dirname . '/' ) .
+                                         'resources/assets/mediawiki.png' );
+               $shortHtml = htmlspecialchars( $shortText );
 
-                       header( 'Content-type: text/html; charset=UTF-8' );
+               header( 'Content-type: text/html; charset=UTF-8' );
 
-                       $finalOutput = <<<HTML
+               $finalOutput = <<<HTML
 <!DOCTYPE html>
 <html lang="en" dir="ltr">
        <head>
                <meta charset="UTF-8" />
-               <title>MediaWiki {$mwVersion}</title>
+               <title>MediaWiki {$this->mwVersion}</title>
                <style media='screen'>
                        body {
                                color: #000;
@@ -144,7 +231,7 @@ function wfGenericError( $type, $mwVersion, $title, $shortText, $longText, $long
        </head>
        <body>
                <img src="{$encLogo}" alt='The MediaWiki logo' />
-               <h1>MediaWiki {$mwVersion} internal error</h1>
+               <h1>MediaWiki {$this->mwVersion} internal error</h1>
                <div class='error'>
                <p>
                        {$shortHtml}
@@ -157,105 +244,59 @@ function wfGenericError( $type, $mwVersion, $title, $shortText, $longText, $long
        </body>
 </html>
 HTML;
-               // Handle everything that's not index.php
-               } else {
-                       // So nothing thinks this is JS or CSS
-                       $finalOutput = ( $type == 'load.php' ) ? "/* $shortText */" : $shortText;
-               }
-       }
-       echo "$finalOutput\n";
-       die( 1 );
-}
-
-/**
- * Display an error for the minimum PHP version requirement not being satisfied.
- *
- * @param string $type See wfGenericError
- * @param string $mwVersion See wfGenericError
- * @param string $minimumVersionPHP The minimum PHP version supported by MediaWiki
- * @param string $phpVersion The current PHP version
- */
-function wfPHPVersionError( $type, $mwVersion, $minimumVersionPHP, $phpVersion ) {
-       $shortText = "MediaWiki $mwVersion requires at least "
-               . "PHP version $minimumVersionPHP, you are using PHP $phpVersion.";
-
-       $longText = "Error: You might be using on older PHP version. \n"
-               . "MediaWiki $mwVersion needs PHP $minimumVersionPHP or higher.\n\n"
-               . "Check if you have a newer php executable with a different name, such as php5.\n\n";
-
-       $longHtml = <<<HTML
-                       Please consider <a href="http://www.php.net/downloads.php">upgrading your copy of PHP</a>.
-                       PHP versions less than 5.5.0 are no longer supported by the PHP Group and will not receive
-                       security or bugfix updates.
-               </p>
-               <p>
-                       If for some reason you are unable to upgrade your PHP version, you will need to
-                       <a href="https://www.mediawiki.org/wiki/Download">download</a> an older version
-                       of MediaWiki from our website.  See our
-                       <a href="https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
-                       for details of which versions are compatible with prior versions of PHP.
-HTML;
-       wfGenericError( $type, $mwVersion, 'Supported PHP versions', $shortText, $longText, $longHtml );
-}
-
-/**
- * Display an error for the vendor/autoload.php file not being found.
- *
- * @param string $type See wfGenericError
- * @param string $mwVersion See wfGenericError
- */
-function wfMissingVendorError( $type, $mwVersion ) {
-       $shortText = "Installing some external dependencies (e.g. via composer) is required.";
 
-       $longText = "Error: You are missing some external dependencies. \n"
-               . "MediaWiki now also has some external dependencies that need to be installed\n"
-               . "via composer or from a separate git repo. Please see\n"
-               . "https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n"
-               . "for help on installing the required components.";
+               return $finalOutput;
+       }
 
-       // @codingStandardsIgnoreStart Generic.Files.LineLength
-       $longHtml = <<<HTML
-               MediaWiki now also has some external dependencies that need to be installed via
-               composer or from a separate git repo. Please see
-               <a href="https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries">mediawiki.org</a>
-               for help on installing the required components.
-HTML;
-       // @codingStandardsIgnoreEnd
+       /**
+        * Display something vaguely comprehensible in the event of a totally unrecoverable error.
+        * Does not assume access to *anything*; no globals, no autoloader, no database, no localisation.
+        * Safe for PHP4 (and putting this here means that WebStart.php and GlobalSettings.php
+        * no longer need to be).
+        *
+        * Calling this function kills execution immediately.
+        *
+        * @param string $title HTML code to be put within an <h2> tag
+        * @param string $shortText
+        * @param string $longText
+        * @param string $longHtml
+        */
+       function triggerError( $title, $shortText, $longText, $longHtml ) {
+               switch ( $this->entryPoint ) {
+                       case 'cli':
+                               $finalOutput = $longText;
+                               break;
+                       case 'index.php':
+                       case 'mw-config/index.php':
+                               $this->outputHTMLHeader();
+                               $finalOutput = $this->getIndexErrorOutput( $title, $longHtml, $shortText );
+                               break;
+                       case 'load.php':
+                               $this->outputHTMLHeader();
+                               $finalOutput = "/* $shortText */";
+                               break;
+                       default:
+                               $this->outputHTMLHeader();
+                               // Handle everything that's not index.php
+                               $finalOutput = $shortText;
+               }
 
-       wfGenericError( $type, $mwVersion, 'External dependencies', $shortText, $longText, $longHtml );
+               echo "$finalOutput\n";
+               die( 1 );
+       }
 }
 
 /**
- * Display an error for a PHP extension not existing.
+ * Check php version and that external dependencies are installed, and
+ * display an informative error if either condition is not satisfied.
  *
- * @param string $type See wfGenericError
- * @param string $mwVersion See wfGenericError
- * @param array $missingExts The extensions we're missing
+ * @note Since we can't rely on anything, the minimum PHP versions and MW current
+ * version are hardcoded here
  */
-function wfMissingExtensions( $type, $mwVersion, $missingExts ) {
-       $shortText = "Installing some PHP extensions is required.";
-
-       $missingExtText = '';
-       $missingExtHtml = '';
-       $baseUrl = 'https://secure.php.net';
-       foreach ( $missingExts as $ext ) {
-               $missingExtText .= " * $ext <$baseUrl/$ext>\n";
-               $missingExtHtml .= "<li><b>$ext</b> "
-                       . "(<a href=\"$baseUrl/$ext\">more information</a>)</li>";
-       }
-
-       $cliText = "Error: Missing one or more required components of PHP.\n"
-               . "You are missing a required extension to PHP that MediaWiki needs.\n"
-               . "Please install:\n" . $missingExtText;
-
-       $longHtml = <<<HTML
-               You are missing a required extension to PHP that MediaWiki
-               requires to run. Please install:
-               <ul>
-               $missingExtHtml
-               </ul>
-HTML;
-
-       wfGenericError( $type, $mwVersion, 'Required components', $shortText,
-               $cliText, $longHtml );
+function wfEntryPointCheck( $entryPoint ) {
+       $phpVersionCheck = new PHPVersionCheck();
+       $phpVersionCheck->setEntryPoint( $entryPoint );
+       $phpVersionCheck->checkRequiredPHPVersion();
+       $phpVersionCheck->checkVendorExistence();
+       $phpVersionCheck->checkExtensionExistence();
 }
index 85ea87c..8df6044 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 /**
- * Mark a revision as patrolled on a page
- *
  * Copyright Â© 2011 Alexandre Emsenhuber
  *
  * This program is free software; you can redistribute it and/or modify
  *
  * @ingroup Actions
  */
-class MarkpatrolledAction extends FormlessAction {
+class MarkpatrolledAction extends FormAction {
 
        public function getName() {
                return 'markpatrolled';
        }
 
        protected function getDescription() {
+               // Disable default header "subtitle"
                return '';
        }
 
-       public function onView() {
-               $request = $this->getRequest();
+       public function getRestriction() {
+               return 'patrol';
+       }
 
-               $rcId = $request->getInt( 'rcid' );
-               $rc = RecentChange::newFromId( $rcId );
-               if ( is_null( $rc ) ) {
+       protected function getRecentChange( $data = null ) {
+               $rc = null;
+               // Note: This works both on initial GET url and after submitting the form
+               $rcId = $data ? intval( $data['rcid'] ) : $this->getRequest()->getInt( 'rcid' );
+               if ( $rcId ) {
+                       $rc = RecentChange::newFromId( $rcId );
+               }
+               if ( !$rc ) {
                        throw new ErrorPageError( 'markedaspatrollederror', 'markedaspatrollederrortext' );
                }
+               return $rc;
+       }
 
-               $user = $this->getUser();
-               if ( !$user->matchEditToken( $request->getVal( 'token' ), $rcId ) ) {
-                       throw new ErrorPageError( 'sessionfailure-title', 'sessionfailure' );
-               }
+       protected function preText() {
+               $rc = $this->getRecentChange();
+               $title = $rc->getTitle();
+
+               // Based on logentry-patrol-patrol (see PatrolLogFormatter)
+               $revId = $rc->getAttribute( 'rc_this_oldid' );
+               $query = [
+                       'curid' => $rc->getAttribute( 'rc_cur_id' ),
+                       'diff' => $revId,
+                       'oldid' => $rc->getAttribute( 'rc_last_oldid' )
+               ];
+               $revlink = Linker::link( $title, htmlspecialchars( $revId ), [], $query );
+               $pagelink = Linker::link( $title, htmlspecialchars( $title->getPrefixedText() ) );
 
+               return $this->msg( 'confirm-markpatrolled-top' )->params(
+                       $title->getPrefixedText(),
+                       // Provide pre-rendered link as parser would render [[:$1]] as bold non-link
+                       Message::rawParam( $pagelink ),
+                       Message::rawParam( $revlink )
+               )->parse();
+       }
+
+       protected function alterForm( HTMLForm $form ) {
+               $form->addHiddenField( 'rcid', $this->getRequest()->getInt( 'rcid' ) );
+               $form->setTokenSalt( 'patrol' );
+               $form->setSubmitTextMsg( 'confirm-markpatrolled-button' );
+       }
+
+       /**
+        * @return bool|array True for success, false for didn't-try, array of errors on failure
+        */
+       public function onSubmit( $data ) {
+               $user = $this->getUser();
+               $rc = $this->getRecentChange( $data );
                $errors = $rc->doMarkPatrolled( $user );
 
                if ( in_array( [ 'rcpatroldisabled' ], $errors ) ) {
                        throw new ErrorPageError( 'rcpatroldisabled', 'rcpatroldisabledtext' );
                }
 
-               if ( in_array( [ 'hookaborted' ], $errors ) ) {
-                       // The hook itself has handled any output
-                       return;
-               }
-
-               # It would be nice to see where the user had actually come from, but for now just guess
+               // Guess where the user came from
+               // TODO: Would be nice to see where the user actually came from
                if ( $rc->getAttribute( 'rc_type' ) == RC_NEW ) {
                        $returnTo = 'Newpages';
                } elseif ( $rc->getAttribute( 'rc_log_type' ) == 'upload' ) {
@@ -76,18 +108,25 @@ class MarkpatrolledAction extends FormlessAction {
                        $this->getOutput()->setPageTitle( $this->msg( 'markedaspatrollederror' ) );
                        $this->getOutput()->addWikiMsg( 'markedaspatrollederror-noautopatrol' );
                        $this->getOutput()->returnToMain( null, $return );
-
-                       return;
+                       return true;
                }
 
-               if ( count( $errors ) ) {
-                       throw new PermissionsError( 'patrol', $errors );
+               if ( $errors ) {
+                       if ( !in_array( [ 'hookaborted' ], $errors ) ) {
+                               throw new PermissionsError( 'patrol', $errors );
+                       }
+                       // The hook itself has handled any output
+                       return $errors;
                }
 
-               # Inform the user
                $this->getOutput()->setPageTitle( $this->msg( 'markedaspatrolled' ) );
                $this->getOutput()->addWikiMsg( 'markedaspatrolledtext', $rc->getTitle()->getPrefixedText() );
                $this->getOutput()->returnToMain( null, $return );
+               return true;
+       }
+
+       public function onSuccess() {
+               // Required by parent class. Redundant as our onSubmit handles output already.
        }
 
        public function doesWrites() {
index 73408ab..a5a8676 100644 (file)
@@ -496,12 +496,11 @@ class DifferenceEngine extends ContextSource {
                                                [
                                                        'action' => 'markpatrolled',
                                                        'rcid' => $linkInfo['rcid'],
-                                                       'token' => $linkInfo['token'],
                                                ]
                                        ) . ']</span>';
                                // Allow extensions to change the markpatrolled link
                                Hooks::run( 'DifferenceEngineMarkPatrolledLink', [ $this,
-                                       &$this->mMarkPatrolledLink, $linkInfo['rcid'], $linkInfo['token'] ] );
+                                       &$this->mMarkPatrolledLink, $linkInfo['rcid'] ] );
                        }
                }
                return $this->mMarkPatrolledLink;
@@ -511,7 +510,7 @@ class DifferenceEngine extends ContextSource {
         * Returns an array of meta data needed to build a "mark as patrolled" link and
         * adds the mediawiki.page.patrol.ajax to the output.
         *
-        * @return array|false An array of meta data for a patrol link (rcid & token)
+        * @return array|false An array of meta data for a patrol link (rcid only)
         *  or false if no link is needed
         */
        protected function getMarkPatrolledLinkInfo() {
@@ -561,10 +560,8 @@ class DifferenceEngine extends ContextSource {
                                        $this->getOutput()->addModules( 'mediawiki.page.patrol.ajax' );
                                }
 
-                               $token = $user->getEditToken( $rcid );
                                return [
                                        'rcid' => $rcid,
-                                       'token' => $token,
                                ];
                        }
                }
index 15f5238..9a2a8e2 100644 (file)
@@ -1184,10 +1184,6 @@ class Article implements Page {
                        return false;
                }
 
-               $rcid = $rc->getAttribute( 'rc_id' );
-
-               $token = $user->getEditToken( $rcid );
-
                $outputPage->preventClickjacking();
                if ( $wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed( 'writeapi' ) ) {
                        $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
@@ -1199,8 +1195,7 @@ class Article implements Page {
                        [],
                        [
                                'action' => 'markpatrolled',
-                               'rcid' => $rcid,
-                               'token' => $token,
+                               'rcid' => $rc->getAttribute( 'rc_id' ),
                        ]
                );
 
index d2da3ad..1e03774 100644 (file)
@@ -763,10 +763,18 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
                $wgAuth->modifyUITemplate( $template, $action );
 
                $oldTemplate = $template;
-               $hookName = $this->isSignup() ? 'UserCreateForm' : 'UserLoginForm';
-               Hooks::run( $hookName, [ &$template ] );
-               if ( $oldTemplate !== $template ) {
-                       wfDeprecated( "reference in $hookName hook", '1.27' );
+
+               // Both Hooks::run are explicit here to make findHooks.php happy
+               if ( $this->isSignup() ) {
+                       Hooks::run( 'UserCreateForm', [ &$template ] );
+                       if ( $oldTemplate !== $template ) {
+                               wfDeprecated( "reference in UserCreateForm hook", '1.27' );
+                       }
+               } else {
+                       Hooks::run( 'UserLoginForm', [ &$template ] );
+                       if ( $oldTemplate !== $template ) {
+                               wfDeprecated( "reference in UserLoginForm hook", '1.27' );
+                       }
                }
 
                return $template;
index 9746ef6..82abccf 100644 (file)
@@ -34,7 +34,7 @@ use MediaWiki\Auth\AuthManager;
  */
 class SpecialPasswordReset extends FormSpecialPage {
        /** @var PasswordReset */
-       private $passwordReset;
+       private $passwordReset = null;
 
        /**
         * @var string[] Temporary storage for the passwords which have been sent out, keyed by username.
@@ -53,7 +53,13 @@ class SpecialPasswordReset extends FormSpecialPage {
 
        public function __construct() {
                parent::__construct( 'PasswordReset', 'editmyprivateinfo' );
-               $this->passwordReset = new PasswordReset( $this->getConfig(), AuthManager::singleton() );
+       }
+
+       private function getPasswordReset() {
+               if ( $this->passwordReset === null ) {
+                       $this->passwordReset = new PasswordReset( $this->getConfig(), AuthManager::singleton() );
+               }
+               return $this->passwordReset;
        }
 
        public function doesWrites() {
@@ -61,11 +67,11 @@ class SpecialPasswordReset extends FormSpecialPage {
        }
 
        public function userCanExecute( User $user ) {
-               return $this->passwordReset->isAllowed( $user )->isGood();
+               return $this->getPasswordReset()->isAllowed( $user )->isGood();
        }
 
        public function checkExecutePermissions( User $user ) {
-               $status = Status::wrap( $this->passwordReset->isAllowed( $user ) );
+               $status = Status::wrap( $this->getPasswordReset()->isAllowed( $user ) );
                if ( !$status->isGood() ) {
                        throw new ErrorPageError( 'internalerror', $status->getMessage() );
                }
@@ -150,7 +156,7 @@ class SpecialPasswordReset extends FormSpecialPage {
 
                $this->method = $username ? 'username' : 'email';
                $this->result = Status::wrap(
-                       $this->passwordReset->execute( $this->getUser(), $username, $email, $capture ) );
+                       $this->getPasswordReset()->execute( $this->getUser(), $username, $email, $capture ) );
                if ( $capture && $this->result->isOK() ) {
                        $this->passwords = $this->result->getValue();
                }
@@ -199,7 +205,7 @@ class SpecialPasswordReset extends FormSpecialPage {
         * @return bool
         */
        public function isListed() {
-               if ( $this->passwordReset->isAllowed( $this->getUser() )->isGood() ) {
+               if ( $this->getPasswordReset()->isAllowed( $this->getUser() )->isGood() ) {
                        return parent::isListed();
                }
 
index dfa9b21..99f36fb 100644 (file)
        "patrol-log-header": "This is a log of patrolled revisions.",
        "log-show-hide-patrol": "$1 patrol log",
        "log-show-hide-tag": "$1 tag log",
+       "confirm-markpatrolled-button": "OK",
+       "confirm-markpatrolled-top": "Mark revision $3 of $2 as patrolled?",
        "deletedrevision": "Deleted old revision $1",
        "filedeleteerror-short": "Error deleting file: $1",
        "filedeleteerror-long": "Errors were encountered while deleting the file:\n\n$1",
index 735d48b..33f1c2a 100644 (file)
        "confirm-unwatch-top": "Used as confirmation message.",
        "confirm-rollback-button": "Used as Submit button text.\n{{Identical|OK}}",
        "confirm-rollback-top": "Used as confirmation message.",
+       "confirm-markpatrolled-button": "Used as Submit button text.\n{{Identical|OK}}",
+       "confirm-markpatrolled-top": "Confirmation message on interstitial form.\n\nParameters:\n* $1 - Target page title\n* $2 - Link to target page with page title as label\n* $3 - Link to recent change diff with revision ID as label",
        "semicolon-separator": "{{optional}}",
        "comma-separator": "{{optional}}\n\nWarning: languages have different usages of punctuation, and sometimes they are swapped (e.g. openining and closing quotation marks, or full stop and colon in Armenian), or change their form (the full stop in Chinese and Japanese, the prefered \"colon\" in Armenian used in fact as the regular full stop, the comma in Arabic, Armenian, and Chinese...)\n\nTheir spacing (before or after) may also vary across languages (for example French requires a non-breaking space, preferably narrow if the browser supports NNBSP, on the inner side of some punctuations like quotation/question/exclamation marks, colon, and semicolons).",
        "colon-separator": "{{optional}}\nChange it only if your language uses another character for ':' or it needs an extra space before the colon.",
index 61d06b6..5e05590 100644 (file)
@@ -65,7 +65,9 @@ function isCompatible( str ) {
                // support in the modern run-time.
                && !(
                        ua.match( /webOS\/1\.[0-4]|SymbianOS|Series60|NetFront|Opera Mini|S40OviBrowser|MeeGo|Android.+Glass/ ) ||
-                       ua.match( /PlayStation/i )
+                       ua.match( /PlayStation/i ) ||
+                       // UC Mini (speed mode on)
+                       ua.match( /^Mozilla\/5\.0 .+ Gecko\/$/ )
                )
        );
 }
index 2d996ae..045b633 100644 (file)
@@ -10,6 +10,7 @@
                        'Mozilla/5.0 (Windows NT 6.1.1; rv:5.0) Gecko/20100101 Firefox/5.0',
                        'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0) Gecko/20100101 Firefox/9.0',
                        'Mozilla/5.0 (Macintosh; I; Intel Mac OS X 11_7_9; de-LI; rv:1.9b4) Gecko/2012010317 Firefox/10.0a4',
+                       'Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0',
                        'Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120403211507 Firefox/12.0',
                        'Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1',
                        // Kindle Fire
@@ -46,6 +47,8 @@
                        'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3',
                        // Android
                        'Mozilla/5.0 (Linux; U; Android 2.1; en-us; Nexus One Build/ERD62) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17',
+                       // UC Mini (speed mode off)
+                       'Mozilla/5.0 (Linux; U; Android 6.0.1; en-US; Nexus_5 Build/MMB29S) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1 UCBrowser/10.7.6.805 Mobile',
 
                        /* Grade C */
 
                        // Google Glass
                        'Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; Glass 1 Build/IMM76L; XE11) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30',
                        // MeeGo
-                       'Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13'
+                       'Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13',
+                       // UC Mini (speed mode on)
+                       'Mozilla/5.0 (X11; U; Linux i686; zh-CN; r:1.2.3.4) Gecko/'
                ]
        };