MediaWiki  master
Go to the documentation of this file.
1 <?php
35 require_once __DIR__ . '/../Maintenance.php';
39  public function __construct() {
40  parent::__construct();
41  $this->addDescription(
42  'Generates a php source file containing a definition for mb_strtoupper overrides' );
43  $this->addOption( 'outfile', 'Output file', true, true, 'o' );
44  $this->addOption( 'override', 'Char table we want to override', true, true );
45  $this->addOption( 'with', 'Char table we want to obtain', true, true );
46  }
48  public function execute() {
49  $outfile = $this->getOption( 'outfile' );
50  $from = $this->loadJson( $this->getOption( 'override' ) );
51  $to = $this->loadJson( $this->getOption( 'with' ) );
52  $overrides = [];
54  foreach ( $from as $lc => $uc ) {
55  $ref = $to[$lc] ?? null;
56  if ( $ref !== null && $ref !== $uc ) {
57  $overrides[$lc] = $ref;
58  }
59  }
60  $writer = new StaticArrayWriter();
61  file_put_contents(
62  $outfile,
63  $writer->create( $overrides, 'File created by generateUcfirstOverrides.php' )
64  );
65  }
67  private function loadJson( $filename ) {
68  $data = file_get_contents( $filename );
69  if ( $data === false ) {
70  $msg = sprintf( "Could not load data from file '%s'\n", $filename );
71  $this->fatalError( $msg );
72  }
73  $json = json_decode( $data, true );
74  if ( $json === null ) {
75  $msg = sprintf( "Invalid json in the data file %s\n", $filename );
76  $this->fatalError( $msg, 2 );
77  }
78  return $json;
79  }
80 }
83 require_once RUN_MAINTENANCE_IF_MAIN;
getOption( $name, $default=null)
Get an option, or return the default.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
Definition: maintenance.txt:50
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 null
Definition: hooks.txt:767
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
Definition: distributors.txt:9
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
Definition: injection.txt:35
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
Definition: maintenance.txt:52
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.