26 'wgLanguageCode' =>
'en',
27 'wgContLang' => Language::factory(
'en' ),
30 $this->tablesUsed[] =
'page';
31 $this->tablesUsed[] =
'revision';
32 $this->tablesUsed[] =
'text';
36 $this->talk_namespace =
NS_TALK;
38 if ( $this->
namespace === $this->talk_namespace ) {
40 throw new MWException(
"The default wikitext namespace is the talk namespace. "
41 .
" We can't currently deal with that." );
44 $this->pageTitle1 = Title::newFromText(
'BackupDumperTestP1', $this->
namespace );
47 "BackupDumperTestP1Text1",
"BackupDumperTestP1Summary1" );
48 $this->pageId1 =
$page->getId();
50 $this->pageTitle2 = Title::newFromText(
'BackupDumperTestP2', $this->
namespace );
53 "BackupDumperTestP2Text1",
"BackupDumperTestP2Summary1" );
55 "BackupDumperTestP2Text2",
"BackupDumperTestP2Summary2" );
57 "BackupDumperTestP2Text3",
"BackupDumperTestP2Summary3" );
59 "BackupDumperTestP2Text4 some additional Text ",
60 "BackupDumperTestP2Summary4 extra " );
61 $this->pageId2 =
$page->getId();
63 $this->pageTitle3 = Title::newFromText(
'BackupDumperTestP3', $this->
namespace );
66 "BackupDumperTestP3Text1",
"BackupDumperTestP2Summary1" );
68 "BackupDumperTestP3Text2",
"BackupDumperTestP2Summary2" );
69 $this->pageId3 =
$page->getId();
70 $page->doDeleteArticle(
"Testing ;)" );
72 $this->pageTitle4 = Title::newFromText(
'BackupDumperTestP1', $this->talk_namespace );
75 "Talk about BackupDumperTestP1 Text1",
76 "Talk BackupDumperTestP1 Summary1" );
77 $this->pageId4 =
$page->getId();
78 }
catch ( Exception
$e ) {
82 $this->exceptionFromAddDBData =
$e;
94 [ $this->pageId2, $this->pageId3, $this->pageId4 ],
95 [ $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ],
96 "Page ids increasing without holes" );
104 $dumper->loadWithArgv( [
'--full',
'--quiet',
'--output',
'file:' .
$fname ] );
106 $dumper->endId = $this->pageId4 + 1;
107 $dumper->setDB( $this->db );
116 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
117 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
118 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87",
119 "BackupDumperTestP1Text1" );
123 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
124 $this->
assertRevision( $this->revId2_1,
"BackupDumperTestP2Summary1",
125 $this->textId2_1, 23,
"jprywrymfhysqllua29tj3sc7z39dl2",
126 "BackupDumperTestP2Text1" );
127 $this->
assertRevision( $this->revId2_2,
"BackupDumperTestP2Summary2",
128 $this->textId2_2, 23,
"b7vj5ks32po5m1z1t1br4o7scdwwy95",
129 "BackupDumperTestP2Text2", $this->revId2_1 );
130 $this->
assertRevision( $this->revId2_3,
"BackupDumperTestP2Summary3",
131 $this->textId2_3, 23,
"jfunqmh1ssfb8rs43r19w98k28gg56r",
132 "BackupDumperTestP2Text3", $this->revId2_2 );
133 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
134 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
135 "BackupDumperTestP2Text4 some additional Text", $this->revId2_3 );
144 $this->talk_namespace,
145 $this->pageTitle4->getPrefixedText()
147 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
148 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe",
149 "Talk about BackupDumperTestP1 Text1" );
160 $dumper->loadWithArgv( [
'--full',
'--quiet',
'--output',
'file:' .
$fname,
'--stub' ] );
162 $dumper->endId = $this->pageId4 + 1;
163 $dumper->setDB( $this->db );
172 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
173 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
174 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
178 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
179 $this->
assertRevision( $this->revId2_1,
"BackupDumperTestP2Summary1",
180 $this->textId2_1, 23,
"jprywrymfhysqllua29tj3sc7z39dl2" );
181 $this->
assertRevision( $this->revId2_2,
"BackupDumperTestP2Summary2",
182 $this->textId2_2, 23,
"b7vj5ks32po5m1z1t1br4o7scdwwy95",
false, $this->revId2_1 );
183 $this->
assertRevision( $this->revId2_3,
"BackupDumperTestP2Summary3",
184 $this->textId2_3, 23,
"jfunqmh1ssfb8rs43r19w98k28gg56r",
false, $this->revId2_2 );
185 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
186 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
195 $this->talk_namespace,
196 $this->pageTitle4->getPrefixedText()
198 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
199 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
211 $dumper->endId = $this->pageId4 + 1;
212 $dumper->reporting =
false;
213 $dumper->setDB( $this->db );
222 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
223 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
224 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
228 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
229 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
230 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
239 $this->talk_namespace,
240 $this->pageTitle4->getPrefixedText()
242 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
243 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
257 $dumper->endId = $this->pageId4 + 1;
258 $dumper->reporting =
false;
259 $dumper->setDB( $this->db );
269 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
270 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
271 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
275 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
276 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
277 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
286 $this->talk_namespace,
287 $this->pageTitle4->getPrefixedText()
289 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
290 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
314 $dumper =
new DumpBackup( [
"--full",
"--stub",
"--output=gzip:" . $fnameMetaHistory,
315 "--output=gzip:" . $fnameMetaCurrent,
"--filter=latest",
316 "--output=gzip:" . $fnameArticles,
"--filter=latest",
317 "--filter=notalk",
"--filter=namespace:!NS_USER",
318 "--reporting=1000" ] );
320 $dumper->endId = $this->pageId4 + 1;
321 $dumper->setDB( $this->db );
327 $dumper->stderr = fopen(
'php://output',
'a' );
328 if ( $dumper->stderr ===
false ) {
329 $this->fail(
"Could not open stream for stderr" );
335 $this->assertTrue( fclose( $dumper->stderr ),
"Closing stderr handle" );
339 $this->
gunzip( $fnameMetaHistory );
343 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
344 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
345 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
349 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
350 $this->
assertRevision( $this->revId2_1,
"BackupDumperTestP2Summary1",
351 $this->textId2_1, 23,
"jprywrymfhysqllua29tj3sc7z39dl2" );
352 $this->
assertRevision( $this->revId2_2,
"BackupDumperTestP2Summary2",
353 $this->textId2_2, 23,
"b7vj5ks32po5m1z1t1br4o7scdwwy95",
false, $this->revId2_1 );
354 $this->
assertRevision( $this->revId2_3,
"BackupDumperTestP2Summary3",
355 $this->textId2_3, 23,
"jfunqmh1ssfb8rs43r19w98k28gg56r",
false, $this->revId2_2 );
356 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
357 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
366 $this->talk_namespace,
367 $this->pageTitle4->getPrefixedText()
369 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
370 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
377 $this->
gunzip( $fnameMetaCurrent );
381 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
382 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
383 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
387 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
388 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
389 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
398 $this->talk_namespace,
399 $this->pageTitle4->getPrefixedText()
401 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
402 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
409 $this->
gunzip( $fnameArticles );
413 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
414 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
415 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
419 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
420 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
421 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Tests for page dumps of BackupDumper.
testXmlDumpsBackupUseCase()
xmldumps-backup typically performs a single dump that that writes out three files
setUp()
Default set up function.
assertPageStart( $id, $ns, $name)
Asserts that the xml reader is at the start of a page element and skips over the first tags,...
assertDumpStart( $fname, $skip_siteinfo=true)
Opens an XML file to analyze and optionally skips past siteinfo.
expectETAOutput()
Checks for test output consisting only of lines containing ETA announcements.
assertPageEnd()
Asserts that the xml reader is at the page's closing element and skips to the next element.
assertDumpEnd( $name="mediawiki")
Asserts that the xml reader is at the final closing tag of an xml file and closes the reader.
addRevision(Page $page, $text, $summary, $model=CONTENT_MODEL_WIKITEXT)
Adds a revision to a page, while returning the resuting revision's id.
gunzip( $fname)
gunzips the given file and stores the result in the original file name
checkHasGzip()
Skip the test if 'gzip' is not in $PATH.
assertRevision( $id, $summary, $text_id, $text_bytes, $text_sha1, $text=false, $parentid=false, $model=CONTENT_MODEL_WIKITEXT, $format=CONTENT_FORMAT_WIKITEXT)
Asserts that the xml reader is at a revision and checks its representation before skipping over it.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
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
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 $page
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