34 $this->tablesUsed[] =
'page';
35 $this->tablesUsed[] =
'revision';
36 $this->tablesUsed[] =
'ip_changes';
37 $this->tablesUsed[] =
'text';
41 $this->talk_namespace =
NS_TALK;
43 if ( $this->
namespace === $this->talk_namespace ) {
45 throw new MWException(
"The default wikitext namespace is the talk namespace. "
46 .
" We can't currently deal with that." );
49 $this->pageTitle1 = Title::newFromText(
'BackupDumperTestP1', $this->
namespace );
50 $page = WikiPage::factory( $this->pageTitle1 );
52 "BackupDumperTestP1Text1",
"BackupDumperTestP1Summary1" );
53 $this->pageId1 = $page->getId();
55 $this->pageTitle2 = Title::newFromText(
'BackupDumperTestP2', $this->
namespace );
56 $page = WikiPage::factory( $this->pageTitle2 );
58 "BackupDumperTestP2Text1",
"BackupDumperTestP2Summary1" );
60 "BackupDumperTestP2Text2",
"BackupDumperTestP2Summary2" );
62 "BackupDumperTestP2Text3",
"BackupDumperTestP2Summary3" );
64 "BackupDumperTestP2Text4 some additional Text ",
65 "BackupDumperTestP2Summary4 extra " );
66 $this->pageId2 = $page->getId();
68 $this->pageTitle3 = Title::newFromText(
'BackupDumperTestP3', $this->
namespace );
69 $page = WikiPage::factory( $this->pageTitle3 );
71 "BackupDumperTestP3Text1",
"BackupDumperTestP2Summary1" );
73 "BackupDumperTestP3Text2",
"BackupDumperTestP2Summary2" );
74 $this->pageId3 = $page->getId();
75 $page->doDeleteArticle(
"Testing ;)" );
77 $this->pageTitle4 = Title::newFromText(
'BackupDumperTestP1', $this->talk_namespace );
78 $page = WikiPage::factory( $this->pageTitle4 );
80 "Talk about BackupDumperTestP1 Text1",
81 "Talk BackupDumperTestP1 Summary1" );
82 $this->pageId4 = $page->getId();
83 }
catch ( Exception
$e ) {
87 $this->exceptionFromAddDBData =
$e;
99 [ $this->pageId2, $this->pageId3, $this->pageId4 ],
100 [ $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ],
101 "Page ids increasing without holes" );
109 $dumper->loadWithArgv( [
'--full',
'--quiet',
'--output',
'file:' .
$fname ] );
111 $dumper->endId = $this->pageId4 + 1;
112 $dumper->setDB( $this->db );
121 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
122 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
123 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87",
124 "BackupDumperTestP1Text1" );
128 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
129 $this->
assertRevision( $this->revId2_1,
"BackupDumperTestP2Summary1",
130 $this->textId2_1, 23,
"jprywrymfhysqllua29tj3sc7z39dl2",
131 "BackupDumperTestP2Text1" );
132 $this->
assertRevision( $this->revId2_2,
"BackupDumperTestP2Summary2",
133 $this->textId2_2, 23,
"b7vj5ks32po5m1z1t1br4o7scdwwy95",
134 "BackupDumperTestP2Text2", $this->revId2_1 );
135 $this->
assertRevision( $this->revId2_3,
"BackupDumperTestP2Summary3",
136 $this->textId2_3, 23,
"jfunqmh1ssfb8rs43r19w98k28gg56r",
137 "BackupDumperTestP2Text3", $this->revId2_2 );
138 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
139 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
140 "BackupDumperTestP2Text4 some additional Text", $this->revId2_3 );
149 $this->talk_namespace,
150 $this->pageTitle4->getPrefixedText()
152 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
153 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe",
154 "Talk about BackupDumperTestP1 Text1" );
165 $dumper->loadWithArgv( [
'--full',
'--quiet',
'--output',
'file:' .
$fname,
'--stub' ] );
167 $dumper->endId = $this->pageId4 + 1;
168 $dumper->setDB( $this->db );
177 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
178 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
179 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
183 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
184 $this->
assertRevision( $this->revId2_1,
"BackupDumperTestP2Summary1",
185 $this->textId2_1, 23,
"jprywrymfhysqllua29tj3sc7z39dl2" );
186 $this->
assertRevision( $this->revId2_2,
"BackupDumperTestP2Summary2",
187 $this->textId2_2, 23,
"b7vj5ks32po5m1z1t1br4o7scdwwy95",
false, $this->revId2_1 );
188 $this->
assertRevision( $this->revId2_3,
"BackupDumperTestP2Summary3",
189 $this->textId2_3, 23,
"jfunqmh1ssfb8rs43r19w98k28gg56r",
false, $this->revId2_2 );
190 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
191 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
200 $this->talk_namespace,
201 $this->pageTitle4->getPrefixedText()
203 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
204 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
216 $dumper->endId = $this->pageId4 + 1;
217 $dumper->reporting =
false;
218 $dumper->setDB( $this->db );
221 $dumper->dump( WikiExporter::CURRENT, WikiExporter::STUB );
227 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
228 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
229 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
233 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
234 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
235 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
244 $this->talk_namespace,
245 $this->pageTitle4->getPrefixedText()
247 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
248 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
262 $dumper->endId = $this->pageId4 + 1;
263 $dumper->reporting =
false;
264 $dumper->setDB( $this->db );
267 $dumper->dump( WikiExporter::CURRENT, WikiExporter::STUB );
274 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
275 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
276 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
280 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
281 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
282 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
291 $this->talk_namespace,
292 $this->pageTitle4->getPrefixedText()
294 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
295 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
319 $dumper =
new DumpBackup( [
"--full",
"--stub",
"--output=gzip:" . $fnameMetaHistory,
320 "--output=gzip:" . $fnameMetaCurrent,
"--filter=latest",
321 "--output=gzip:" . $fnameArticles,
"--filter=latest",
322 "--filter=notalk",
"--filter=namespace:!NS_USER",
323 "--reporting=1000" ] );
325 $dumper->endId = $this->pageId4 + 1;
326 $dumper->setDB( $this->db );
332 $dumper->stderr = fopen(
'php://output',
'a' );
333 if ( $dumper->stderr ===
false ) {
334 $this->fail(
"Could not open stream for stderr" );
338 $dumper->dump( WikiExporter::FULL, WikiExporter::STUB );
340 $this->assertTrue( fclose( $dumper->stderr ),
"Closing stderr handle" );
344 $this->
gunzip( $fnameMetaHistory );
348 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
349 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
350 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
354 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
355 $this->
assertRevision( $this->revId2_1,
"BackupDumperTestP2Summary1",
356 $this->textId2_1, 23,
"jprywrymfhysqllua29tj3sc7z39dl2" );
357 $this->
assertRevision( $this->revId2_2,
"BackupDumperTestP2Summary2",
358 $this->textId2_2, 23,
"b7vj5ks32po5m1z1t1br4o7scdwwy95",
false, $this->revId2_1 );
359 $this->
assertRevision( $this->revId2_3,
"BackupDumperTestP2Summary3",
360 $this->textId2_3, 23,
"jfunqmh1ssfb8rs43r19w98k28gg56r",
false, $this->revId2_2 );
361 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
362 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
371 $this->talk_namespace,
372 $this->pageTitle4->getPrefixedText()
374 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
375 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
382 $this->
gunzip( $fnameMetaCurrent );
386 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
387 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
388 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
392 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
393 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
394 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
403 $this->talk_namespace,
404 $this->pageTitle4->getPrefixedText()
406 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
407 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
414 $this->
gunzip( $fnameArticles );
418 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
419 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
420 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
424 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
425 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
426 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
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.
gunzip( $fname)
gunzips the given file and stores the result in the original file name
assertDumpStart( $fname, $skip_siteinfo=true)
Opens an XML file to analyze and optionally skips past siteinfo.
assertPageEnd()
Asserts that the xml reader is at the page's closing element and skips to the next element.
addRevision(Page $page, $text, $summary, $model=CONTENT_MODEL_WIKITEXT)
Adds a revision to a page, while returning the resuting revision's id.
assertDumpEnd( $name="mediawiki")
Asserts that the xml reader is at the final closing tag of an xml file and closes the reader.
expectETAOutput()
Checks for test output consisting only of lines containing ETA announcements.
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.
assertPageStart( $id, $ns, $name)
Asserts that the xml reader is at the start of a page element and skips over the first tags,...
Represents a title within MediaWiki.
Class representing a MediaWiki article and history.
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
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