27require_once __DIR__ .
'/backup.inc';
28require_once __DIR__ .
'/../includes/export/WikiExporter.php';
97 parent::__construct();
100This script postprocesses XML dumps
from dumpBackup.php to
add
101page text which was stubbed out (
using --stub).
103XML input
is accepted
on stdin.
107 $this->stderr = fopen(
"php://stderr",
"wt" );
109 $this->
addOption(
'stub',
'To load a compressed stub dump instead of stdin. ' .
110 'Specify as --stub=<type>:<file>.',
false,
true );
111 $this->
addOption(
'prefetch',
'Use a prior dump file as a text source, to savepressure on the ' .
112 'database. (Requires the XMLReader extension). Specify as --prefetch=<type>:<file>',
114 $this->
addOption(
'maxtime',
'Write out checkpoint file after this many minutes (writing' .
115 'out complete page, closing xml file properly, and opening new one' .
116 'with header). This option requires the checkpointfile option.',
false,
true );
117 $this->
addOption(
'checkpointfile',
'Use this string for checkpoint filenames,substituting ' .
118 'first pageid written for the first %s (required) and the last pageid written for the ' .
119 'second %s if it exists.',
false,
true,
false,
true );
120 $this->
addOption(
'quiet',
'Don\'t dump status reports to stderr.' );
121 $this->
addOption(
'current',
'Base ETA on number of pages in database instead of all revisions' );
122 $this->
addOption(
'spawn',
'Spawn a subprocess for loading text records' );
123 $this->
addOption(
'buffersize',
'Buffer size in bytes to use for reading the stub. ' .
124 '(Default: 512KB, Minimum: 4KB)',
false,
true );
140 parent::processOptions();
142 if ( $this->
hasOption(
'buffersize' ) ) {
143 $this->bufferSize = max( intval( $this->
getOption(
'buffersize' ) ), 4 * 1024 );
147 require_once
"$IP/maintenance/backupPrefetch.inc";
149 $this->prefetch =
new BaseDump( $url );
157 $this->maxTimeAllowed = intval( $this->
getOption(
'maxtime' ) ) * 60;
160 if ( $this->
hasOption(
'checkpointfile' ) ) {
161 $this->checkpointFiles = $this->
getOption(
'checkpointfile' );
194 if ( isset( $this->lb ) ) {
195 $this->lb->closeAll();
199 if ( $this->forcedDb !==
null ) {
205 if ( isset( $this->db ) && $this->db->isOpen() ) {
206 throw new MWException(
'DB is set and has not been closed by the Load Balancer' );
218 }
catch ( Exception
$e ) {
220 .
" rotating DB failed to obtain new load balancer (" .
$e->getMessage() .
")" );
225 $this->db = $this->lb->getConnection(
DB_REPLICA,
'dump' );
226 }
catch ( Exception
$e ) {
228 .
" rotating DB failed to obtain new database (" .
$e->getMessage() .
")" );
233 parent::initProgress();
234 $this->timeOfCheckpoint = $this->startTime;
240 if ( ini_get(
'display_errors' ) ) {
241 ini_set(
'display_errors',
'stderr' );
253 }
catch ( Exception
$e ) {
256 $this->
progress(
"Getting initial DB connection failed (" .
257 $e->getMessage() .
")" );
268 $input = fopen( $this->input,
"rt" );
271 if ( $this->spawnProc ) {
279 $split = explode(
':', $opt, 2 );
282 if ( count( $split ) === 2 ) {
285 $fileURIs = explode(
';', $param );
286 foreach ( $fileURIs
as $URI ) {
292 $newURI =
"compress.zlib://$URI";
295 $newURI =
"compress.bzip2://$URI";
298 $newURI =
"mediawiki.compress.7z://$URI";
303 $newFileURIs[] = $newURI;
305 $val = implode(
';', $newFileURIs );
314 if ( !$this->prefetch ) {
315 parent::showReport();
320 if ( $this->reporting ) {
322 $nowts = microtime(
true );
323 $deltaAll = $nowts - $this->startTime;
329 $portion = $this->
revCount / $this->maxCount;
330 $eta = $this->startTime + $deltaAll / $portion;
332 if ( $this->fetchCount ) {
337 $pageRate = $this->pageCount / $deltaAll;
338 $revRate = $this->
revCount / $deltaAll;
346 if ( $this->fetchCountLast ) {
349 $fetchRatePart =
'-';
351 $pageRatePart = $this->pageCountPart / $deltaPart;
352 $revRatePart = $this->revCountPart / $deltaPart;
354 $fetchRatePart =
'-';
359 "%s: %s (ID %d) %d pages (%0.1f|%0.1f/sec all|curr), "
360 .
"%d revs (%0.1f|%0.1f/sec all|curr), %0.1f%%|%0.1f%% "
361 .
"prefetched (all|curr), ETA %s [max %d]",
362 $now,
wfWikiID(), $this->ID, $this->pageCount, $pageRate,
363 $pageRatePart, $this->
revCount, $revRate, $revRatePart,
364 $fetchRate, $fetchRatePart, $etats, $this->maxCount
366 $this->lastTime = $nowts;
374 $this->timeExceeded =
true;
378 if ( $this->maxTimeAllowed
379 && ( $this->lastTime - $this->timeOfCheckpoint > $this->maxTimeAllowed )
388 if ( ( $this->checkpointFiles && !$this->maxTimeAllowed )
389 || ( $this->maxTimeAllowed && !$this->checkpointFiles )
391 throw new MWException(
"Options checkpointfile and maxtime must be specified together.\n" );
393 foreach ( $this->checkpointFiles
as $checkpointFile ) {
394 $count = substr_count( $checkpointFile,
"%s" );
396 throw new MWException(
"Option checkpointfile must contain two '%s' "
397 .
"for substitution of first and last pageids, count is $count instead, "
398 .
"file is $checkpointFile.\n" );
402 if ( $this->checkpointFiles ) {
403 $filenameList = (
array)$this->egress->getFilenames();
404 if ( count( $filenameList ) != count( $this->checkpointFiles ) ) {
405 throw new MWException(
"One checkpointfile must be specified "
406 .
"for each output option, if maxtime is used.\n" );
418 $this->openElement =
false;
419 $this->atStart =
true;
421 $this->lastName =
"";
424 $this->thisRevModel =
null;
425 $this->thisRevFormat =
null;
427 $parser = xml_parser_create(
"UTF-8" );
428 xml_parser_set_option(
$parser, XML_OPTION_CASE_FOLDING,
false );
430 xml_set_element_handler(
432 [ $this,
'startElement' ],
433 [ $this,
'endElement' ]
435 xml_set_character_data_handler(
$parser, [ $this,
'characterData' ] );
442 $chunk = fread(
$input, $this->bufferSize );
444 wfDebug(
"TextDumpPass::readDump encountered XML parsing error\n" );
446 $byte = xml_get_current_byte_index(
$parser );
448 'XML import parse failure',
449 xml_get_current_line_number(
$parser ),
450 xml_get_current_column_number(
$parser ),
451 $byte . ( is_null( $chunk ) ?
null : (
'; "' . substr( $chunk, $byte - $offset, 16 ) .
'"' ) ),
452 xml_error_string( xml_get_error_code(
$parser ) ) )->escaped();
458 $offset += strlen( $chunk );
459 }
while ( $chunk !==
false && !feof(
$input ) );
460 if ( $this->maxTimeAllowed ) {
461 $filenameList = (
array)$this->egress->getFilenames();
463 if ( file_exists( $filenameList[0] ) ) {
465 # we might have just written the header and footer and had no
466 # pages or revisions written... perhaps they were all deleted
467 # there's no pageID 0 so we use that. the caller is responsible
468 # for deciding what to do with a file containing only the
469 # siteinfo information and the mw tags.
470 if ( !$this->firstPageWritten ) {
471 $firstPageID = str_pad( 0, 9,
"0", STR_PAD_LEFT );
472 $lastPageID = str_pad( 0, 9,
"0", STR_PAD_LEFT );
474 $firstPageID = str_pad( $this->firstPageWritten, 9,
"0", STR_PAD_LEFT );
475 $lastPageID = str_pad( $this->lastPageWritten, 9,
"0", STR_PAD_LEFT );
478 $filenameCount = count( $filenameList );
479 for ( $i = 0; $i < $filenameCount; $i++ ) {
480 $checkpointNameFilledIn = sprintf( $this->checkpointFiles[$i], $firstPageID, $lastPageID );
481 $fileinfo = pathinfo( $filenameList[$i] );
482 $newFilenames[] =
$fileinfo[
'dirname'] .
'/' . $checkpointNameFilledIn;
484 $this->egress->closeAndRename( $newFilenames );
504 $text =
$handler->exportTransform( $text, $format );
508 "Unable to apply export transformation for content model '$model': " .
536 function getText( $id, $model =
null, $format =
null ) {
539 $prefetchNotTried =
true;
544 static $consecutiveFailedTextRetrievals = 0;
551 $oldConsecutiveFailedTextRetrievals = $consecutiveFailedTextRetrievals;
552 $consecutiveFailedTextRetrievals = 0;
555 $row = $this->db->selectRow(
557 [
'rev_content_model',
'rev_content_format' ],
558 [
'rev_id' => $this->thisRev ],
563 $model = $row->rev_content_model;
564 $format = $row->rev_content_format;
568 if ( $model ===
null || $model ===
'' ) {
572 while ( $failures < $this->maxFailures ) {
583 if ( $text ===
false && isset( $this->prefetch ) && $prefetchNotTried ) {
584 $prefetchNotTried =
false;
585 $tryIsPrefetch =
true;
586 $text = $this->prefetch->prefetch( intval( $this->thisPage ),
587 intval( $this->thisRev ) );
589 if ( $text ===
null ) {
593 if ( is_string( $text ) && $model !==
false ) {
603 if ( $text ===
false ) {
605 $tryIsPrefetch =
false;
606 if ( $this->spawn ) {
612 if ( $text !==
false && $model !==
false ) {
621 if ( $text !==
false ) {
626 if ( $text ===
false ) {
627 throw new MWException(
"Generic error while obtaining text for id " . $id );
634 $revID = intval( $this->thisRev );
635 if ( !isset( $this->db ) ) {
640 $revLength = strlen( $text );
642 $revLength = $this->db->selectField(
'revision',
'rev_len', [
'rev_id' => $revID ] );
645 if ( strlen( $text ) == $revLength ) {
646 if ( $tryIsPrefetch ) {
647 $this->prefetchCount++;
654 throw new MWException(
"Received text is unplausible for id " . $id );
655 }
catch ( Exception
$e ) {
656 $msg =
"getting/checking text " . $id .
" failed (" .
$e->getMessage() .
")";
657 if ( $failures + 1 < $this->maxFailures ) {
658 $msg .=
" (Will retry " . ( $this->maxFailures - $failures - 1 ) .
" more times)";
667 if ( !$tryIsPrefetch ) {
671 sleep( $this->failureTimeout );
674 if ( $this->spawn ) {
678 }
catch ( Exception
$e ) {
679 $this->
progress(
"Rebooting getText infrastructure failed (" . $e->getMessage() .
")" .
680 " Trying to continue anyways" );
690 $consecutiveFailedTextRetrievals = $oldConsecutiveFailedTextRetrievals + 1;
691 if ( $consecutiveFailedTextRetrievals > $this->maxConsecutiveFailedTextRetrievals ) {
692 throw new MWException(
"Graceful storage failure" );
706 if ( !isset( $this->db ) ) {
707 throw new MWException( __METHOD__ .
"No database available" );
709 $row = $this->db->selectRow(
'text',
710 [
'old_text',
'old_flags' ],
714 if ( $text ===
false ) {
717 $stripped = str_replace(
"\r",
"", $text );
724 MediaWiki\suppressWarnings();
725 if ( !$this->spawnProc ) {
730 MediaWiki\restoreWarnings();
738 if ( file_exists(
"$IP/../multiversion/MWScript.php" ) ) {
740 array_map(
'wfEscapeShellArg',
743 "$IP/../multiversion/MWScript.php",
748 array_map(
'wfEscapeShellArg',
751 "$IP/maintenance/fetchText.php",
755 0 => [
"pipe",
"r" ],
756 1 => [
"pipe",
"w" ],
757 2 => [
"file",
"/dev/null",
"a" ] ];
760 $this->
progress(
"Spawning database subprocess: $cmd" );
761 $this->spawnProc = proc_open( $cmd, $spec, $pipes );
762 if ( !$this->spawnProc ) {
763 $this->
progress(
"Subprocess spawn failed." );
776 MediaWiki\suppressWarnings();
777 if ( $this->spawnRead ) {
778 fclose( $this->spawnRead );
780 $this->spawnRead =
false;
781 if ( $this->spawnWrite ) {
782 fclose( $this->spawnWrite );
784 $this->spawnWrite =
false;
785 if ( $this->spawnErr ) {
786 fclose( $this->spawnErr );
788 $this->spawnErr =
false;
789 if ( $this->spawnProc ) {
790 pclose( $this->spawnProc );
792 $this->spawnProc =
false;
793 MediaWiki\restoreWarnings();
799 $ok = fwrite( $this->spawnWrite,
"$id\n" );
805 $ok = fflush( $this->spawnWrite );
813 $newId = fgets( $this->spawnRead );
814 if ( $newId ===
false ) {
817 if ( $id != intval( $newId ) ) {
821 $len = fgets( $this->spawnRead );
823 if ( $len ===
false ) {
827 $nbytes = intval( $len );
836 while ( $nbytes > strlen( $text ) ) {
837 $buffer = fread( $this->spawnRead, $nbytes - strlen( $text ) );
844 $gotbytes = strlen( $text );
845 if ( $gotbytes != $nbytes ) {
846 $this->
progress(
"Expected $nbytes bytes from database subprocess, got $gotbytes " );
852 $stripped = str_replace(
"\r",
"", $text );
859 $this->checkpointJustWritten =
false;
862 $this->lastName =
$name;
864 if (
$name ==
'revision' ) {
865 $this->state =
$name;
866 $this->egress->writeOpenPage(
null, $this->buffer );
868 } elseif (
$name ==
'page' ) {
869 $this->state =
$name;
870 if ( $this->atStart ) {
871 $this->egress->writeOpenStream( $this->buffer );
873 $this->atStart =
false;
879 $model = trim( $this->thisRevModel );
880 $format = trim( $this->thisRevFormat );
882 $model = $model ===
'' ? null : $model;
883 $format = $format ===
'' ? null : $format;
885 $text = $this->
getText( $id, $model, $format );
886 $this->openElement = [
$name, [
'xml:space' =>
'preserve' ] ];
887 if ( strlen( $text ) > 0 ) {
896 $this->checkpointJustWritten =
false;
898 if ( $this->openElement ) {
901 $this->buffer .=
"</$name>";
904 if (
$name ==
'revision' ) {
905 $this->egress->writeRevision(
null, $this->buffer );
908 $this->thisRevModel =
null;
909 $this->thisRevFormat =
null;
910 } elseif (
$name ==
'page' ) {
911 if ( !$this->firstPageWritten ) {
912 $this->firstPageWritten = trim( $this->thisPage );
914 $this->lastPageWritten = trim( $this->thisPage );
915 if ( $this->timeExceeded ) {
916 $this->egress->writeClosePage( $this->buffer );
919 $this->egress->sink->write(
"\n" );
921 $this->buffer = $this->xmlwriterobj->closeStream();
922 $this->egress->writeCloseStream( $this->buffer );
925 $this->thisPage =
"";
928 $filenameList = (
array)$this->egress->getFilenames();
930 $firstPageID = str_pad( $this->firstPageWritten, 9,
"0", STR_PAD_LEFT );
931 $lastPageID = str_pad( $this->lastPageWritten, 9,
"0", STR_PAD_LEFT );
932 $filenamesCount = count( $filenameList );
933 for ( $i = 0; $i < $filenamesCount; $i++ ) {
934 $checkpointNameFilledIn = sprintf( $this->checkpointFiles[$i], $firstPageID, $lastPageID );
935 $fileinfo = pathinfo( $filenameList[$i] );
936 $newFilenames[] =
$fileinfo[
'dirname'] .
'/' . $checkpointNameFilledIn;
938 $this->egress->closeRenameAndReopen( $newFilenames );
939 $this->buffer = $this->xmlwriterobj->openStream();
940 $this->timeExceeded =
false;
942 $this->firstPageWritten =
false;
943 $this->checkpointJustWritten =
true;
945 $this->egress->writeClosePage( $this->buffer );
947 $this->thisPage =
"";
949 } elseif (
$name ==
'mediawiki' ) {
950 $this->egress->writeCloseStream( $this->buffer );
957 if ( $this->lastName ==
"id" ) {
958 if ( $this->state ==
"revision" ) {
959 $this->thisRev .= $data;
960 } elseif ( $this->state ==
"page" ) {
961 $this->thisPage .= $data;
963 } elseif ( $this->lastName ==
"model" ) {
964 $this->thisRevModel .= $data;
965 } elseif ( $this->lastName ==
"format" ) {
966 $this->thisRevFormat .= $data;
971 if ( $this->checkpointJustWritten ) {
972 if ( $data[0] ==
"\n" ) {
973 $data = substr( $data, 1 );
975 $this->checkpointJustWritten =
false;
977 $this->buffer .= htmlspecialchars( $data );
981 if ( $this->openElement ) {
982 $this->buffer .=
Xml::element( $this->openElement[0], $this->openElement[1], $style );
983 $this->openElement =
false;
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable from
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetLBFactory()
Get the load balancer factory object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
IDatabase null $forcedDb
The dependency-injected database to use.
Readahead helper for making large MediaWiki data dumps; reads in a previous XML dump to sequentially ...
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
Relational database abstraction object.
hasOption( $name)
Checks to see if a particular param exists.
addDescription( $text)
Set the description text.
loadWithArgv( $argv)
Load params and arguments from a given array of command-line arguments.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row $row is usually an object from wfFetchRow(),...
$maxConsecutiveFailedTextRetrievals
showReport()
Overridden to include prefetch ratio if enabled.
getTextDb( $id)
May throw a database error if, say, the server dies during query.
endElement( $parser, $name)
clearOpenElement( $style)
getText( $id, $model=null, $format=null)
Tries to get the revision text for a revision id.
exportTransform( $text, $model, $format=null)
Applies applicable export transformations to $text.
startElement( $parser, $name, $attribs)
processOptions()
Processes arguments and sets $this->$sink accordingly.
characterData( $parser, $data)
initProgress( $history=WikiExporter::FULL)
Initialise starting time and maximum revision count.
execute()
Do the actual work.
dump( $history, $text=WikiExporter::TEXT)
bool XmlDumpWriter $xmlwriterobj
bool resource $spawnWrite
rotateDb()
Drop the database connection $this->db and try to get a new one.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
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
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
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 list
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
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 in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
when a variable name is used in a it is silently declared as a new local masking the global
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
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
const CONTENT_MODEL_WIKITEXT
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead $parser
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc next in line in page history
An extension or a local will often add custom code to the function with or without a global variable For someone wanting email notification when an article is shown may add
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 "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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 an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk page
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 on
Allows to change the fields on the form that will be generated $name
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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 modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
returning false will NOT prevent logging $e
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
require_once RUN_MAINTENANCE_IF_MAIN
const TS_DB
MySQL DATETIME (YYYY-MM-DD HH:MM:SS)