Merge "maintenance: Deprecate Maintenance::hasArg/getArg with no param"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 31 Mar 2019 16:36:23 +0000 (16:36 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 31 Mar 2019 16:36:23 +0000 (16:36 +0000)
1  2 
RELEASE-NOTES-1.33
maintenance/Maintenance.php

diff --combined RELEASE-NOTES-1.33
@@@ -109,7 -109,6 +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 ====
@@@ -346,8 -345,6 +346,8 @@@ because of Phabricator reports
    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.
 +* MessageBlobStore::getBlob(), deprecated in 1.27, has been removed.
 +  Use ::getBlobs() instead.
  
  === Deprecations in 1.33 ===
  * The configuration option $wgUseESI has been deprecated, and is expected
    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.
+ * Calling Maintenance::hasArg() as well as Maintenance::getArg() with no
+   parameter has been deprecated. Please pass the argument number 0.
  
  === Other changes in 1.33 ===
  * (T201747) Html::openElement() warns if given an element name with a space
@@@ -54,18 -54,6 +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
   */
@@@ -81,13 -69,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
         * @return bool
         */
        protected function hasArg( $argId = 0 ) {
+               if ( func_num_args() === 0 ) {
+                       wfDeprecated( __METHOD__ . ' without an $argId', '1.33' );
+               }
                return isset( $this->mArgs[$argId] );
        }
  
         * @return mixed
         */
        protected function getArg( $argId = 0, $default = null ) {
+               if ( func_num_args() === 0 ) {
+                       wfDeprecated( __METHOD__ . ' without an $argId', '1.33' );
+               }
                return $this->hasArg( $argId ) ? $this->mArgs[$argId] : $default;
        }
  
                }
  
                $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();
        }
  
        /**
        /**
         * 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 );
        }
  
        /**