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 ====
'MagicWordwgVariableIDs': When defining new magic words IDs.
&$variableIDs: array of strings
+'MaintenanceUpdateAddParams': allow extensions to add params to the update.php
+maintenance script.
+&$params: array to populate with the params to be added. Array elements are keyed by
+the param name. Each param is an associative array that must include the following keys:
+ - desc The description of the param to show on --help
+ - require Is the param required? Defaults to false if not set.
+ - withArg Is an argument required with this option? Defaults to false if not set.
+ - shortName Character to use as short name, or false if none. Defaults to false if not set.
+ - multiOccurrence Can this option be passed multiple times? Defaults to false if not set.
+
'MaintenanceRefreshLinksInit': before executing the refreshLinks.php maintenance
script.
$refreshLinks: RefreshLinks object
* 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
*/
// 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();
}
/**
/**
* 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 );
}
/**
// This avoids having long running scripts just OOM and lose all the updates.
$maintenance->setAgentAndTriggers();
+$maintenance->validateParamsAndArgs();
+
// Do the work
$success = $maintenance->execute();
$this->addOption( 'format', implode( ', ', self::$outFormats ), false, true );
}
- protected function validateParamsAndArgs() {
+ public function validateParamsAndArgs() {
$error_out = false;
# Get the format and make sure it is set to a valid default value
'manualRecache' => false,
];
}
+
+ public function validateParamsAndArgs() {
+ // Allow extensions to add additional params.
+ $params = [];
+ Hooks::run( 'MaintenanceUpdateAddParams', [ &$params ] );
+ foreach ( $params as $name => $param ) {
+ $this->addOption(
+ $name,
+ $param['desc'],
+ $param['require'] ?? false,
+ $param['withArg'] ?? false,
+ $param['shortName'] ?? false,
+ $param['multiOccurrence'] ?? false
+ );
+ }
+
+ parent::validateParamsAndArgs();
+ }
}
$maintClass = UpdateMediaWiki::class;