Go to the documentation of this file.
12 parent::__construct(
$name, $data, $dataName );
14 $this->tablesUsed = array_merge( $this->tablesUsed,
37 'iw_prefix' =>
'linksupdatetest',
38 'iw_url' =>
'http://testing.com/wiki/$1',
39 'iw_api' =>
'http://testing.com/w/api.php',
42 'iw_wikiid' =>
'linksupdatetest',
45 $this->
setMwGlobals(
'wgRCWatchCategoryMembership',
true );
50 self::$testingPageId =
$res[
'id'];
52 $this->
insertPage(
'Template:TestingTemplate' );
57 $t->mArticleID = $id; # XXX:
this is fugly
60 $po->setTitleText(
$t->getPrefixedText() );
84 'pl_from = ' . self::$testingPageId,
89 ], $update->getAddedLinks() );
92 $po->setTitleText(
$t->getPrefixedText() );
103 'pl_from = ' . self::$testingPageId,
112 ], $update->getAddedLinks() );
115 ], $update->getRemovedLinks() );
125 $po->addExternalLink(
"http://testing.com/wiki/Foo" );
132 'el_from = ' . self::$testingPageId,
134 [
'http://testing.com/wiki/Foo',
'http://com.testing./wiki/Foo' ],
144 $this->
setMwGlobals(
'wgCategoryCollation',
'uppercase' );
148 $po->addCategory(
"Foo",
"FOO" );
155 'cl_from = ' . self::$testingPageId,
156 [ [
'Foo',
"FOO\nTESTING" ] ]
161 $this->
setMwGlobals(
'wgCategoryCollation',
'uppercase' );
165 $wikiPage->doEditContent(
new WikitextContent(
'[[Category:Foo]]' ),
'added category' );
172 [ [
'Foo',
'[[:Testing]] added to category' ] ]
175 $wikiPage->doEditContent(
new WikitextContent(
'[[Category:Bar]]' ),
'replaced category' );
183 [
'Foo',
'[[:Testing]] added to category' ],
184 [
'Foo',
'[[:Testing]] removed from category' ],
193 [
'Bar',
'[[:Testing]] added to category' ],
199 $this->
setMwGlobals(
'wgCategoryCollation',
'uppercase' );
202 $templatePage =
new WikiPage( $templateTitle );
205 $wikiPage->doEditContent(
new WikitextContent(
'{{TestingTemplate}}' ),
'added template' );
209 $otherWikiPage->doEditContent(
new WikitextContent(
'{{TestingTemplate}}' ),
'added template' );
219 $templatePage->doEditContent(
new WikitextContent(
'[[Category:Baz]]' ),
'added category' );
228 '[[:Template:TestingTemplate]] added to category, ' .
229 '[[Special:WhatLinksHere/Template:TestingTemplate|this page is included within other pages]]'
242 $po->addInterwikiLink( $target );
248 'iwl_prefix, iwl_title',
249 'iwl_from = ' . self::$testingPageId,
250 [ [
'linksupdatetest',
'Foo' ] ]
269 'tl_from = ' . self::$testingPageId,
281 $po->addImage(
"Foo.png" );
288 'il_from = ' . self::$testingPageId,
298 'wgCapitalLinks' =>
true,
311 'll_from = ' . self::$testingPageId,
325 $fields = [
'pp_propname',
'pp_value' ];
328 $po->setProperty(
"bool",
true );
329 $expected[] = [
"bool",
true ];
331 $po->setProperty(
"float", 4.0 + 1.0 / 4.0 );
332 $expected[] = [
"float", 4.0 + 1.0 / 4.0 ];
334 $po->setProperty(
"int", -7 );
335 $expected[] = [
"int", -7 ];
337 $po->setProperty(
"string",
"33 bar" );
338 $expected[] = [
"string",
"33 bar" ];
342 $fields[] =
'pp_sortkey';
344 foreach ( $expected
as &$row ) {
348 $row[] = floatval(
$value );
356 $t, $po,
'page_props', $fields,
'pp_page = ' . self::$testingPageId, $expected );
368 $table, $fields, $condition,
array $expectedRows
374 $this->
assertSelect( $table, $fields, $condition, $expectedRows );
386 'rc_title, rc_comment',
390 'rc_title' => $categoryTitle->
getDBkey()
397 [
'recentchanges',
'comment' ],
398 'rc_title, comment_text',
402 'rc_title' => $categoryTitle->
getDBkey(),
403 'comment_id = rc_comment_id',
412 while (
$job = $queueGroup->pop(
'refreshLinksPrioritized' ) ) {
414 $queueGroup->ack(
$job );
416 while (
$job = $queueGroup->pop(
'categoryMembershipChange' ) ) {
418 $queueGroup->ack(
$job );
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
testUpdate_templatelinks()
ParserOutput::addTemplate.
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
int $wgCommentTableSchemaMigrationStage
Comment table schema migration stage.
testUpdate_iwlinks()
ParserOutput::addInterwikiLink.
Class representing a MediaWiki article and history.
testUpdate_pagelinks()
ParserOutput::addLink.
Class the manages updates of *_link tables as well as similar extension-managed tables.
const MIGRATION_WRITE_BOTH
testUpdate_externallinks()
ParserOutput::addExternalLink.
Allows to change the fields on the form that will be generated $name
testOnAddingAndRemovingCategory_recentChangesRowIsAdded()
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
static newCanonical(User $user=null, $lang=null)
Creates a "canonical" ParserOptions object.
testUpdate_page_props()
ParserOutput::setProperty.
testUpdate_page_props_without_sortkey()
getDBkey()
Get the main part with underscores.
namespace and then decline to actually register it file or subcat img or subcat $title
assertRecentChangeByCategorization(Title $pageTitle, ParserOutput $parserOutput, Title $categoryTitle, $expectedRows)
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
when a variable name is used in a it is silently declared as a new masking the global
testUpdate_langlinks()
ParserOutput::addLanguageLink.
Content object for wiki text pages.
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
makeTitleAndParserOutput( $name, $id)
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
assertLinksUpdate(Title $title, ParserOutput $parserOutput, $table, $fields, $condition, array $expectedRows)
testUpdate_categorylinks()
ParserOutput::addCategory.
__construct( $name=null, array $data=[], $dataName='')
testOnAddingAndRemovingCategoryToTemplates_embeddingPagesAreIgnored()
Represents a title within MediaWiki.
LinksUpdate Database ^— make sure temporary tables are used.
if(count( $args)< 1) $job
static singleton( $wiki=false)
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
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
$wgPagePropsHaveSortkey
Whether the page_props table has a pp_sortkey column.
testUpdate_imagelinks()
ParserOutput::addImage.
the array() calling protocol came about after MediaWiki 1.4rc1.