Go to the documentation of this file.
26 require_once __DIR__ .
'/Maintenance.php';
51 parent::__construct();
52 $this->
addDescription(
'Get serialized MediaWiki site configuration' );
53 $this->
addOption(
'regex',
'regex to filter variables with',
false,
true );
54 $this->
addOption(
'iregex',
'same as --regex but case insensitive',
false,
true );
55 $this->
addOption(
'settings',
'Space-separated list of wg* variables',
false,
true );
56 $this->
addOption(
'format', implode(
', ', self::$outFormats ),
false,
true );
62 # Get the format and make sure it is set to a valid default value
63 $format = strtolower( $this->
getOption(
'format',
'PHP' ) );
65 $validFormat = in_array( $format, self::$outFormats );
66 if ( !$validFormat ) {
67 $this->
error(
"--format set to an unrecognized format" );
72 $this->
error(
"Can only use either --regex or --iregex" );
76 parent::validateParamsAndArgs();
92 $this->regex =
'/' . $this->regex .
'/';
94 $this->regex .=
'i'; #
case insensitive regex
99 $this->settings_list = explode(
' ', $this->
getOption(
'settings' ) );
101 foreach ( $this->settings_list
as $name ) {
102 if ( !preg_match(
'/^wg[A-Z]/',
$name ) ) {
103 throw new MWException(
"Variable '$name' does start with 'wg'." );
105 throw new MWException(
"Variable '$name' is not set." );
107 throw new MWException(
"Variable '$name' includes non-array, non-scalar, items." );
117 # Sane default: dump any wg / wmg variable
118 if ( !$this->regex && !$this->
getOption(
'settings' ) ) {
119 $this->regex =
'/^wm?g/';
122 # Filter out globals based on the regex
123 if ( $this->regex ) {
126 if ( preg_match( $this->regex,
$name ) ) {
132 # Explicitly dumps a list of provided global names
133 if ( $this->settings_list ) {
134 foreach ( $this->settings_list
as $name ) {
142 switch ( strtolower( $this->
getOption(
'format' ) ) ) {
154 throw new MWException(
"Invalid serialization format given." );
156 if ( !is_string(
$out ) ) {
157 throw new MWException(
"Failed to serialize the requested settings." );
168 ob_start(); # intercept var_dump()
output
171 # grab var_dump() output and discard it from the output buffer
172 $ret .= trim( ob_get_clean() ) .
";\n";
175 return trim(
$ret,
"\n" );
179 if ( is_array(
$value ) ) {
execute()
Do the actual work.
maybeHelp( $force=false)
Maybe show the help.
addDescription( $text)
Set the description text.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
__construct()
Default constructor.
finalSetup()
finalSetup() since we need MWException
require_once RUN_MAINTENANCE_IF_MAIN
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Print serialized output of MediaWiki config vars.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
static $outFormats
List of format output internally supported.
Allows to change the fields on the form that will be generated $name
validateParamsAndArgs()
Run some validation checks on the params, etc.
isAllowedVariable( $value)
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
getOption( $name, $default=null)
Get an option, or return the default.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
hasOption( $name)
Checks to see if a particular option exists.