MediaWiki  1.31.0
replaceAll.php
Go to the documentation of this file.
1 #!/usr/bin/php
2 <?php
32 // @codingStandardsIgnoreStart
33 $IP = getenv( "MW_INSTALL_PATH" ) ? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
34 if ( !is_readable( "$IP/maintenance/Maintenance.php" ) ) {
35  die( "MW_INSTALL_PATH needs to be set to your MediaWiki installation.\n" );
36 }
37 require_once ( "$IP/maintenance/Maintenance.php" );
38 // @codingStandardsIgnoreEnd
39 
47 class ReplaceAll extends Maintenance {
48  private $user;
49  private $target;
50  private $replacement;
51  private $namespaces;
52  private $category;
53  private $prefix;
54  private $useRegex;
55  private $titles;
57  private $doAnnounce;
58 
59  public function __construct() {
60  parent::__construct();
61  $this->mDescription = "CLI utility to replace text wherever it is ".
62  "found in the wiki.";
63 
64  $this->addArg( "target", "Target text to find.", false );
65  $this->addArg( "replace", "Text to replace.", false );
66 
67  $this->addOption( "dry-run", "Only find the texts, don't replace.",
68  false, false, 'n' );
69  $this->addOption( "regex", "This is a regex (false).",
70  false, false, 'r' );
71  $this->addOption( "user", "The user to attribute this to (uid 1).",
72  false, true, 'u' );
73  $this->addOption( "yes", "Skip all prompts with an assumed 'yes'.",
74  false, false, 'y' );
75  $this->addOption( "summary", "Alternate edit summary. (%r is where to ".
76  " place the replacement text, %f the text to look for.)",
77  false, true, 's' );
78  $this->addOption( "nsall", "Search all canonical namespaces (false). " .
79  "If true, this option overrides the ns option.", false, false, 'a' );
80  $this->addOption( "ns", "Comma separated namespaces to search in " .
81  "(Main) .", false, true );
82  $this->addOption( "replacements", "File containing the list of " .
83  "replacements to be made. Fields in the file are tab-separated. " .
84  "See --show-file-format for more information.", false, true, "f" );
85  $this->addOption( "show-file-format", "Show a description of the " .
86  "file format to use with --replacements.", false, false );
87  $this->addOption( "no-announce", "Do not announce edits on Special:RecentChanges or " .
88  "watchlists.", false, false, "m" );
89  $this->addOption( "debug", "Display replacements being made.", false, false );
90  $this->addOption( "listns", "List out the namespaces on this wiki.",
91  false, false );
92 
93  // MW 1.28
94  if ( method_exists( $this, 'requireExtension' ) ) {
95  $this->requireExtension( 'Replace Text' );
96  }
97  }
98 
99  private function getUser() {
100  $userReplacing = $this->getOption( "user", 1 );
101 
102  $user = is_numeric( $userReplacing ) ?
103  User::newFromId( $userReplacing ) :
104  User::newFromName( $userReplacing );
105 
106  if ( get_class( $user ) !== 'User' ) {
107  $this->error(
108  "Couldn't translate '$userReplacing' to a user.", true
109  );
110  }
111 
112  return $user;
113  }
114 
115  private function getTarget() {
116  $ret = $this->getArg( 0 );
117  if ( !$ret ) {
118  $this->error( "You have to specify a target.", true );
119  }
120  return [ $ret ];
121  }
122 
123  private function getReplacement() {
124  $ret = $this->getArg( 1 );
125  if ( !$ret ) {
126  $this->error( "You have to specify replacement text.", true );
127  }
128  return [ $ret ];
129  }
130 
131  private function getReplacements() {
132  $file = $this->getOption( "replacements" );
133  if ( !$file ) {
134  return false;
135  }
136 
137  if ( !is_readable( $file ) ) {
138  throw new MWException( "File does not exist or is not readable: "
139  . "$file\n" );
140  }
141 
142  $handle = fopen( $file, "r" );
143  if ( $handle === false ) {
144  throw new MWException( "Trouble opening file: $file\n" );
145  return false;
146  }
147 
148  $this->defaultContinue = true;
149  // @codingStandardsIgnoreStart
150  while ( ( $line = fgets( $handle ) ) !== false ) {
151  // @codingStandardsIgnoreEnd
152  $field = explode( "\t", substr( $line, 0, -1 ) );
153  if ( !isset( $field[1] ) ) {
154  continue;
155  }
156 
157  $this->target[] = $field[0];
158  $this->replacement[] = $field[1];
159  $this->useRegex[] = isset( $field[2] ) ? true : false;
160  }
161  return true;
162  }
163 
164  private function shouldContinueByDefault() {
165  if ( !is_bool( $this->defaultContinue ) ) {
166  $this->defaultContinue =
167  $this->getOption( "yes" ) ?
168  true :
169  false;
170  }
171  return $this->defaultContinue;
172  }
173 
174  private function getSummary( $target, $replacement ) {
175  $msg = wfMessage( 'replacetext_editsummary', $target, $replacement )->
176  plain();
177  if ( $this->getOption( "summary" ) !== null ) {
178  $msg = str_replace( [ '%f', '%r' ],
179  [ $this->target, $this->replacement ],
180  $this->getOption( "summary" ) );
181  }
182  return $msg;
183  }
184 
185  private function listNamespaces() {
186  echo "Index\tNamespace\n";
188  ksort( $nsList );
189  foreach ( $nsList as $int => $val ) {
190  if ( $val == "" ) {
191  $val = "(main)";
192  }
193  echo " $int\t$val\n";
194  }
195  }
196 
197  private function showFileFormat() {
198 echo <<<EOF
199 
200 The format of the replacements file is tab separated with three fields.
201 Any line that does not have a tab is ignored and can be considered a comment.
202 
203 Fields are:
204 
205  1. String to search for.
206  2. String to replace found text with.
207  3. (optional) The presence of this field indicates that the previous two
208  are considered a regular expression.
209 
210 Example:
211 
212 This is a comment
213 TARGET REPLACE
214 regex(p*) Count the Ps; \\1 true
215 
216 
217 EOF;
218  }
219 
220  private function getNamespaces() {
221  $nsall = $this->getOption( "nsall" );
222  $ns = $this->getOption( "ns" );
223  if ( !$nsall && !$ns ) {
224  $namespaces = [ NS_MAIN ];
225  } else {
227  $canonical[NS_MAIN] = "_";
228  $namespaces = array_flip( $canonical );
229  if ( !$nsall ) {
230  $namespaces = array_map(
231  function ( $n ) use ( $canonical, $namespaces ) {
232  if ( is_numeric( $n ) ) {
233  if ( isset( $canonical[ $n ] ) ) {
234  return intval( $n );
235  }
236  } else {
237  if ( isset( $namespaces[ $n ] ) ) {
238  return $namespaces[ $n ];
239  }
240  }
241  return null;
242  }, explode( ",", $ns ) );
243  $namespaces = array_filter(
244  $namespaces,
245  function ( $val ) {
246  return $val !== null;
247  } );
248  }
249  }
250  return $namespaces;
251  }
252 
253  private function getCategory() {
254  $cat = null;
255  return $cat;
256  }
257 
258  private function getPrefix() {
259  $prefix = null;
260  return $prefix;
261  }
262 
263  private function useRegex() {
264  return [ $this->getOption( "regex" ) ];
265  }
266 
267  private function getTitles( $res ) {
268  if ( !$this->titles || count( $this->titles ) == 0 ) {
269  $this->titles = [];
270  foreach ( $res as $row ) {
271  $this->titles[] = Title::makeTitleSafe(
272  $row->page_namespace,
273  $row->page_title
274  );
275  }
276  }
277  return $this->titles;
278  }
279 
280  private function listTitles( $res ) {
281  $ret = false;
282  foreach ( $this->getTitles( $res ) as $title ) {
283  $ret = true;
284  echo "$title\n";
285  }
286  return $ret;
287  }
288 
290  foreach ( $this->getTitles( $res ) as $title ) {
291  $param = [
292  'target_str' => $target,
293  'replacement_str' => $replacement,
294  'use_regex' => $useRegex,
295  'user_id' => $this->user->getId(),
296  'edit_summary' => $this->getSummary( $target, $replacement ),
297  'doAnnounce' => $this->doAnnounce
298  ];
299  echo "Replacing on $title... ";
300  $job = new ReplaceTextJob( $title, $param );
301  if ( $job->run() !== true ) {
302  $this->error( "Trouble on the page '$title'." );
303  }
304  echo "done.\n";
305  }
306  }
307 
308  private function getReply( $question ) {
309  $reply = "";
310  if ( $this->shouldContinueByDefault() ) {
311  return true;
312  }
313  while ( $reply !== "y" && $reply !== "n" ) {
314  $reply = $this->readconsole( "$question (Y/N) " );
315  $reply = substr( strtolower( $reply ), 0, 1 );
316  }
317  return $reply === "y";
318  }
319 
320  private function localSetup() {
321  if ( $this->getOption( "listns" ) ) {
322  $this->listNamespaces();
323  return false;
324  }
325  if ( $this->getOption( "show-file-format" ) ) {
326  $this->showFileFormat();
327  return false;
328  }
329  $this->user = $this->getUser();
330  if ( ! $this->getReplacements() ) {
331  $this->target = $this->getTarget();
332  $this->replacement = $this->getReplacement();
333  $this->useRegex = $this->useRegex();
334  }
335  $this->namespaces = $this->getNamespaces();
336  $this->category = $this->getCategory();
337  $this->prefix = $this->getPrefix();
338  return true;
339  }
340 
344  public function execute() {
346  $wgShowExceptionDetails = true;
347 
348  $this->doAnnounce = true;
349  if ( $this->localSetup() ) {
350  if ( $this->namespaces === [] ) {
351  $this->error( "No matching namespaces.", true );
352  }
353 
354  foreach ( array_keys( $this->target ) as $index ) {
355  $target = $this->target[$index];
356  $replacement = $this->replacement[$index];
357  $useRegex = $this->useRegex[$index];
358 
359  if ( $this->getOption( "debug" ) ) {
360  echo "Replacing '$target' with '$replacement'";
361  if ( $useRegex ) {
362  echo " as regular expression.";
363  }
364  echo "\n";
365  }
367  $this->namespaces, $this->category, $this->prefix,
368  $useRegex );
369 
370  if ( $res->numRows() === 0 ) {
371  $this->error( "No targets found to replace.", true );
372  }
373  if ( $this->getOption( "dry-run" ) ) {
374  $this->listTitles( $res );
375  return;
376  }
377  if ( !$this->shouldContinueByDefault() &&
378  $this->listTitles( $res ) ) {
379  if ( !$this->getReply(
380  "Replace instances on these pages?"
381  ) ) {
382  return;
383  }
384  }
385  $comment = "";
386  if ( $this->getOption( "user", null ) === null ) {
387  $comment = " (Use --user to override)";
388  }
389  if ( $this->getOption( "no-announce", false ) ) {
390  $this->doAnnounce = false;
391  }
392  if ( !$this->getReply(
393  "Attribute changes to the user '{$this->user}'?$comment"
394  ) ) {
395  return;
396  }
397  if ( $res->numRows() > 0 ) {
398  $this->replaceTitles(
400  );
401  }
402  }
403  }
404  }
405 }
406 
407 $maintClass = "ReplaceAll";
408 require_once RUN_MAINTENANCE_IF_MAIN;
ReplaceAll\$titles
$titles
Definition: replaceAll.php:55
$maintClass
$maintClass
Definition: replaceAll.php:388
User\newFromId
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition: User.php:614
file
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
Definition: hooks.txt:91
ReplaceAll\showFileFormat
showFileFormat()
Definition: replaceAll.php:197
ReplaceAll\$useRegex
$useRegex
Definition: replaceAll.php:54
is
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for except in special pages derived from QueryPage It s a common pitfall for new developers to submit code containing SQL queries which examine huge numbers of rows Remember that COUNT * is(N), counting rows in atable is like counting beans in a bucket.------------------------------------------------------------------------ Replication------------------------------------------------------------------------The largest installation of MediaWiki, Wikimedia, uses a large set ofslave MySQL servers replicating writes made to a master MySQL server. Itis important to understand the issues associated with this setup if youwant to write code destined for Wikipedia.It 's often the case that the best algorithm to use for a given taskdepends on whether or not replication is in use. Due to our unabashedWikipedia-centrism, we often just use the replication-friendly version, but if you like, you can use wfGetLB() ->getServerCount() > 1 tocheck to see if replication is in use.===Lag===Lag primarily occurs when large write queries are sent to the master.Writes on the master are executed in parallel, but they are executed inserial when they are replicated to the slaves. The master writes thequery to the binlog when the transaction is committed. The slaves pollthe binlog and start executing the query as soon as it appears. They canservice reads while they are performing a write query, but will not readanything more from the binlog and thus will perform no more writes. Thismeans that if the write query runs for a long time, the slaves will lagbehind the master for the time it takes for the write query to complete.Lag can be exacerbated by high read load. MediaWiki 's load balancer willstop sending reads to a slave when it is lagged by more than 30 seconds.If the load ratios are set incorrectly, or if there is too much loadgenerally, this may lead to a slave permanently hovering around 30seconds lag.If all slaves are lagged by more than 30 seconds, MediaWiki will stopwriting to the database. All edits and other write operations will berefused, with an error returned to the user. This gives the slaves achance to catch up. Before we had this mechanism, the slaves wouldregularly lag by several minutes, making review of recent editsdifficult.In addition to this, MediaWiki attempts to ensure that the user seesevents occurring on the wiki in chronological order. A few seconds of lagcan be tolerated, as long as the user sees a consistent picture fromsubsequent requests. This is done by saving the master binlog positionin the session, and then at the start of each request, waiting for theslave to catch up to that position before doing any reads from it. Ifthis wait times out, reads are allowed anyway, but the request isconsidered to be in "lagged slave mode". Lagged slave mode can bechecked by calling wfGetLB() ->getLaggedSlaveMode(). The onlypractical consequence at present is a warning displayed in the pagefooter.===Lag avoidance===To avoid excessive lag, queries which write large numbers of rows shouldbe split up, generally to write one row at a time. Multi-row INSERT ...SELECT queries are the worst offenders should be avoided altogether.Instead do the select first and then the insert.===Working with lag===Despite our best efforts, it 's not practical to guarantee a low-lagenvironment. Lag will usually be less than one second, but mayoccasionally be up to 30 seconds. For scalability, it 's very importantto keep load on the master low, so simply sending all your queries tothe master is not the answer. So when you have a genuine need forup-to-date data, the following approach is advised:1) Do a quick query to the master for a sequence number or timestamp 2) Run the full query on the slave and check if it matches the data you gotfrom the master 3) If it doesn 't, run the full query on the masterTo avoid swamping the master every time the slaves lag, use of thisapproach should be kept to a minimum. In most cases you should just readfrom the slave and let the user deal with the delay.------------------------------------------------------------------------ Lock contention------------------------------------------------------------------------Due to the high write rate on Wikipedia(and some other wikis), MediaWiki developers need to be very careful to structure their writesto avoid long-lasting locks. By default, MediaWiki opens a transactionat the first query, and commits it before the output is sent. Locks willbe held from the time when the query is done until the commit. So youcan reduce lock time by doing as much processing as possible before youdo your write queries.Often this approach is not good enough, and it becomes necessary toenclose small groups of queries in their own transaction. Use thefollowing syntax:$dbw=wfGetDB(DB_MASTER
ReplaceAll\getReply
getReply( $question)
Definition: replaceAll.php:308
captcha-old.count
count
Definition: captcha-old.py:249
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
ReplaceAll\$category
$category
Definition: replaceAll.php:52
ReplaceAll\$target
$target
Definition: replaceAll.php:49
Maintenance\readconsole
static readconsole( $prompt='> ')
Prompt the console for input.
Definition: Maintenance.php:1524
ReplaceAll\getTarget
getTarget()
Definition: replaceAll.php:115
ReplaceAll\$doAnnounce
$doAnnounce
Definition: replaceAll.php:57
ReplaceAll\getCategory
getCategory()
Definition: replaceAll.php:253
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
ReplaceAll\getReplacement
getReplacement()
Definition: replaceAll.php:123
ReplaceAll\execute
execute()
@inheritDoc
Definition: replaceAll.php:344
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:591
a
</source > ! result< div class="mw-highlight mw-content-ltr" dir="ltr">< pre >< span ></span >< span class="kd"> var</span >< span class="nx"> a</span >< span class="p"></span ></pre ></div > ! end ! test Multiline< source/> in lists !input *< source > a b</source > *foo< source > a b</source > ! html< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! html tidy< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! end ! test Custom attributes !input< source lang="javascript" id="foo" class="bar" dir="rtl" style="font-size: larger;"> var a
Definition: parserTests.txt:89
$res
$res
Definition: database.txt:21
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
ReplaceAll\__construct
__construct()
Default constructor.
Definition: replaceAll.php:59
php
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
ReplaceAll\$prefix
$prefix
Definition: replaceAll.php:53
NS_MAIN
const NS_MAIN
Definition: Defines.php:65
namespaces
to move a page</td >< td > &*You are moving the page across namespaces
Definition: All_system_messages.txt:2670
MWException
MediaWiki exception.
Definition: MWException.php:26
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
user
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 and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Definition: distributors.txt:9
ReplaceAll\getPrefix
getPrefix()
Definition: replaceAll.php:258
ReplaceAll\listTitles
listTitles( $res)
Definition: replaceAll.php:280
ReplaceAll\localSetup
localSetup()
Definition: replaceAll.php:320
ReplaceTextJob
Background job to replace text in a given page.
Definition: ReplaceTextJob.php:29
not
if not
Definition: COPYING.txt:307
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
Definition: Maintenance.php:219
Maintenance\requireExtension
requireExtension( $name)
Indicate that the specified extension must be loaded before the script can run.
Definition: Maintenance.php:572
ReplaceAll\getSummary
getSummary( $target, $replacement)
Definition: replaceAll.php:174
replace
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place replace
Definition: hooks.txt:2220
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
ReplaceAll\useRegex
useRegex()
Definition: replaceAll.php:263
$line
$line
Definition: cdb.php:59
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:562
ReplaceAll\listNamespaces
listNamespaces()
Definition: replaceAll.php:185
ReplaceAll\getTitles
getTitles( $res)
Definition: replaceAll.php:267
ReplaceAll\shouldContinueByDefault
shouldContinueByDefault()
Definition: replaceAll.php:164
ReplaceAll\$user
$user
Definition: replaceAll.php:48
$ret
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
Definition: hooks.txt:1987
captcha-old.p
p
Definition: captcha-old.py:275
format
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1649
plain
either a plain
Definition: hooks.txt:2048
ReplaceAll\$defaultContinue
$defaultContinue
Definition: replaceAll.php:56
ReplaceAll\getNamespaces
getNamespaces()
Definition: replaceAll.php:220
and
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:254
ReplaceAll\getUser
getUser()
Definition: replaceAll.php:99
ReplaceAll\$replacement
$replacement
Definition: replaceAll.php:50
ReplaceTextSearch\doSearchQuery
static doSearchQuery( $search, $namespaces, $category, $prefix, $use_regex=false)
Definition: ReplaceTextSearch.php:34
are
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types are
Definition: contenthandler.txt:5
$job
if(count( $args)< 1) $job
Definition: recompressTracked.php:47
ReplaceAll
Maintenance script that replaces text in pages.
Definition: replaceAll.php:47
Maintenance\addArg
addArg( $arg, $description, $required=true)
Add some args that are needed.
Definition: Maintenance.php:271
$wgShowExceptionDetails
$wgShowExceptionDetails
If set to true, uncaught exceptions will print a complete stack trace to output.
Definition: DefaultSettings.php:6248
as
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
MWNamespace\getCanonicalNamespaces
static getCanonicalNamespaces( $rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
Definition: MWNamespace.php:230
$IP
$IP
Definition: replaceAll.php:33
true
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 just before the function returns a value If you return true
Definition: hooks.txt:1987
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:416
of
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
Definition: globals.txt:10
wfMessage
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
that
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if that
Definition: deferred.txt:11
ReplaceAll\getReplacements
getReplacements()
Definition: replaceAll.php:131
Maintenance\getArg
getArg( $argId=0, $default=null)
Get an argument.
Definition: Maintenance.php:310
ReplaceAll\$namespaces
$namespaces
Definition: replaceAll.php:51
line
I won t presume to tell you how to I m just describing the methods I chose to use for myself If you do choose to follow these it will probably be easier for you to collaborate with others on the but if you want to contribute without by all means do which work well I also use K &R brace matching style I know that s a religious issue for so if you want to use a style that puts opening braces on the next line
Definition: design.txt:79
ReplaceAll\replaceTitles
replaceTitles( $res, $target, $replacement, $useRegex)
Definition: replaceAll.php:289