Merge "Allow extensions to add params to the update.php maintenance script"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 29 Mar 2019 16:33:55 +0000 (16:33 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 29 Mar 2019 16:33:55 +0000 (16:33 +0000)
1  2 
RELEASE-NOTES-1.33
maintenance/Maintenance.php

diff --combined RELEASE-NOTES-1.33
@@@ -109,6 -109,7 +109,7 @@@ For notes on 1.32.x and older releases
    Content::getNativeData() for text-based content models.
  * (T214706) LinksUpdate::getAddedExternalLinks() and
    LinksUpdate::getRemovedExternalLinks() were introduced.
+ * (T213893) Added 'MaintenanceUpdateAddParams' hook
  
  === External library changes in 1.33 ===
  ==== New external libraries ====
  * Added jakub-onderka/php-console-highlighter 0.3.2 explicitly (dev-only).
  
  ==== Changed external libraries ====
 -* Updated OOUI from v0.29.2 to v0.31.1.
 +* Updated OOUI from v0.29.2 to v0.31.2.
  * Updated OOjs Router from pre-release to v0.2.0.
  * Updated moment from v2.19.3 to v2.24.0.
  * Updated wikimedia/xmp-reader from 0.6.0 to 0.6.2.
  * Updated wikimedia/php-session-serializer from 1.0.6 to 1.0.7.
  
  ==== Removed external libraries ====
 -* 
 +* (T219403) jquery.ui.spinner, deprecated since 1.31, was removed.
  
  === Bug fixes in 1.33 ===
  * (T164211) Special:UserRights could sometimes fail with a
@@@ -341,10 -342,6 +342,10 @@@ because of Phabricator reports
    Use CdnCacheUpdate::newFromTitles() instead.
  * Handling of multiple arguments by the Block constructor, deprecated in 1.26,
    has been removed.
 +* The translation of main page in Sardinian (sc) was changed from "Pàgina Base"
 +  to "Pàgina printzipale". Existing wikis using this content language need to
 +  move the main page or change the name through MediaWiki:Mainpage page.
 +* wfSplitWikiID(), deprecated in 1.32, has been removed.
  
  === Deprecations in 1.33 ===
  * The configuration option $wgUseESI has been deprecated, and is expected
  * ManualLogEntry::setTags() is deprecated, use ManualLogEntry::addTags()
    instead. The setTags() method was overriding the tags, addTags() doesn't
    override, only adds new tags.
 +* Block::isValid is deprecated, since it is no longer needed in core.
  
  === Other changes in 1.33 ===
  * (T201747) Html::openElement() warns if given an element name with a space
    changed to explicitly cast. Subclasses relying on the base-class
    implementation should check whether they need to override it now.
  * BagOStuff::add is now abstract and must explicitly be defined in subclasses.
 +* LinksDeletionUpdate is now a subclass of LinksUpdate. As a consequence,
 +  the following hooks will now be triggered upon page deletion in addition
 +  to page updates: LinksUpdateConstructed, LinksUpdate, LinksUpdateComplete.
 +  LinksUpdateAfterInsert is not triggered since deletions do not cause
 +  insertions into links tables.
  
  == Compatibility ==
  MediaWiki 1.33 requires PHP 7.0.13 or later. Although HHVM 3.18.5 or later is
@@@ -54,6 -54,18 +54,18 @@@ use Wikimedia\Rdbms\IMaintainableDataba
   * is the execute() method. See docs/maintenance.txt for more info
   * and a quick demo of how to use it.
   *
+  * Terminology:
+  *   params: registry of named values that may be passed to the script
+  *   arg list: registry of positional values that may be passed to the script
+  *   options: passed param values
+  *   args: passed positional values
+  *
+  * In the command:
+  *   mwscript somescript.php --foo=bar baz
+  * foo is a param
+  * bar is the option value of the option for param foo
+  * baz is the arg value at index 0 in the arg list
+  *
   * @since 1.16
   * @ingroup Maintenance
   */
@@@ -69,13 -81,13 +81,13 @@@ abstract class Maintenance 
        // Const for getStdin()
        const STDIN_ALL = 'all';
  
-       // This is the desired params
+       // Array of desired/allowed params
        protected $mParams = [];
  
        // Array of mapping short parameters to long ones
        protected $mShortParamsMap = [];
  
-       // Array of desired args
+       // Array of desired/allowed args
        protected $mArgList = [];
  
        // This is the list of options that were actually passed
                }
  
                $this->loadParamsAndArgs();
-               $this->maybeHelp();
  
                # Set the memory limit
                # Note we need to set it again later in cache LocalSettings changed it
                while ( ob_get_level() > 0 ) {
                        ob_end_flush();
                }
-               $this->validateParamsAndArgs();
        }
  
        /**
                                        $this->setParam( $options, $option, $param );
                                } else {
                                        $bits = explode( '=', $option, 2 );
 -                                      if ( count( $bits ) > 1 ) {
 -                                              $option = $bits[0];
 -                                              $param = $bits[1];
 -                                      } else {
 -                                              $param = 1;
 -                                      }
 -
 -                                      $this->setParam( $options, $option, $param );
 +                                      $this->setParam( $options, $bits[0], $bits[1] ?? 1 );
                                }
                        } elseif ( $arg == '-' ) {
                                # Lonely "-", often used to indicate stdin or stdout.
        /**
         * Run some validation checks on the params, etc
         */
-       protected function validateParamsAndArgs() {
+       public function validateParamsAndArgs() {
                $die = false;
                # Check to make sure we've got all the required options
                foreach ( $this->mParams as $opt => $info ) {
                        }
                }
  
-               if ( $die ) {
-                       $this->maybeHelp( true );
-               }
+               $this->maybeHelp( $die );
        }
  
        /**
                }
                if ( isset( $this->mOptions['wiki'] ) ) {
                        $bits = explode( '-', $this->mOptions['wiki'], 2 );
 -                      if ( count( $bits ) == 1 ) {
 -                              $bits[] = '';
 -                      }
                        define( 'MW_DB', $bits[0] );
 -                      define( 'MW_PREFIX', $bits[1] );
 +                      define( 'MW_PREFIX', $bits[1] ?? '' );
                } elseif ( isset( $this->mOptions['server'] ) ) {
                        // Provide the option for site admins to detect and configure
                        // multiple wikis based on server names. This offers --server