34 'wgLanguageCode' =>
'en',
35 'wgContLang' => Language::factory(
'en' ),
38 $this->tablesUsed[] =
'page';
39 $this->tablesUsed[] =
'revision';
40 $this->tablesUsed[] =
'ip_changes';
41 $this->tablesUsed[] =
'text';
45 $this->talk_namespace =
NS_TALK;
47 if ( $this->
namespace === $this->talk_namespace ) {
49 throw new MWException(
"The default wikitext namespace is the talk namespace. "
50 .
" We can't currently deal with that." );
53 $this->pageTitle1 = Title::newFromText(
'BackupDumperTestP1', $this->
namespace );
54 $page = WikiPage::factory( $this->pageTitle1 );
56 "BackupDumperTestP1Text1",
"BackupDumperTestP1Summary1" );
57 $this->pageId1 = $page->getId();
59 $this->pageTitle2 = Title::newFromText(
'BackupDumperTestP2', $this->
namespace );
60 $page = WikiPage::factory( $this->pageTitle2 );
62 "BackupDumperTestP2Text1",
"BackupDumperTestP2Summary1" );
64 "BackupDumperTestP2Text2",
"BackupDumperTestP2Summary2" );
66 "BackupDumperTestP2Text3",
"BackupDumperTestP2Summary3" );
68 "BackupDumperTestP2Text4 some additional Text ",
69 "BackupDumperTestP2Summary4 extra " );
70 $this->pageId2 = $page->getId();
72 $this->pageTitle3 = Title::newFromText(
'BackupDumperTestP3', $this->
namespace );
73 $page = WikiPage::factory( $this->pageTitle3 );
75 "BackupDumperTestP3Text1",
"BackupDumperTestP2Summary1" );
77 "BackupDumperTestP3Text2",
"BackupDumperTestP2Summary2" );
78 $this->pageId3 = $page->getId();
79 $page->doDeleteArticle(
"Testing ;)" );
81 $this->pageTitle4 = Title::newFromText(
'BackupDumperTestP1', $this->talk_namespace );
82 $page = WikiPage::factory( $this->pageTitle4 );
84 "Talk about BackupDumperTestP1 Text1",
85 "Talk BackupDumperTestP1 Summary1" );
86 $this->pageId4 = $page->getId();
87 }
catch ( Exception
$e ) {
91 $this->exceptionFromAddDBData =
$e;
103 [ $this->pageId2, $this->pageId3, $this->pageId4 ],
104 [ $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ],
105 "Page ids increasing without holes" );
113 $dumper->loadWithArgv( [
'--full',
'--quiet',
'--output',
'file:' .
$fname ] );
115 $dumper->endId = $this->pageId4 + 1;
116 $dumper->setDB( $this->db );
125 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
126 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
127 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87",
128 "BackupDumperTestP1Text1" );
132 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
133 $this->
assertRevision( $this->revId2_1,
"BackupDumperTestP2Summary1",
134 $this->textId2_1, 23,
"jprywrymfhysqllua29tj3sc7z39dl2",
135 "BackupDumperTestP2Text1" );
136 $this->
assertRevision( $this->revId2_2,
"BackupDumperTestP2Summary2",
137 $this->textId2_2, 23,
"b7vj5ks32po5m1z1t1br4o7scdwwy95",
138 "BackupDumperTestP2Text2", $this->revId2_1 );
139 $this->
assertRevision( $this->revId2_3,
"BackupDumperTestP2Summary3",
140 $this->textId2_3, 23,
"jfunqmh1ssfb8rs43r19w98k28gg56r",
141 "BackupDumperTestP2Text3", $this->revId2_2 );
142 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
143 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
144 "BackupDumperTestP2Text4 some additional Text", $this->revId2_3 );
153 $this->talk_namespace,
154 $this->pageTitle4->getPrefixedText()
156 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
157 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe",
158 "Talk about BackupDumperTestP1 Text1" );
169 $dumper->loadWithArgv( [
'--full',
'--quiet',
'--output',
'file:' .
$fname,
'--stub' ] );
171 $dumper->endId = $this->pageId4 + 1;
172 $dumper->setDB( $this->db );
181 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
182 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
183 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
187 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
188 $this->
assertRevision( $this->revId2_1,
"BackupDumperTestP2Summary1",
189 $this->textId2_1, 23,
"jprywrymfhysqllua29tj3sc7z39dl2" );
190 $this->
assertRevision( $this->revId2_2,
"BackupDumperTestP2Summary2",
191 $this->textId2_2, 23,
"b7vj5ks32po5m1z1t1br4o7scdwwy95",
false, $this->revId2_1 );
192 $this->
assertRevision( $this->revId2_3,
"BackupDumperTestP2Summary3",
193 $this->textId2_3, 23,
"jfunqmh1ssfb8rs43r19w98k28gg56r",
false, $this->revId2_2 );
194 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
195 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
204 $this->talk_namespace,
205 $this->pageTitle4->getPrefixedText()
207 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
208 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
220 $dumper->endId = $this->pageId4 + 1;
221 $dumper->reporting =
false;
222 $dumper->setDB( $this->db );
225 $dumper->dump( WikiExporter::CURRENT, WikiExporter::STUB );
231 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
232 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
233 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
237 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
238 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
239 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
248 $this->talk_namespace,
249 $this->pageTitle4->getPrefixedText()
251 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
252 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
266 $dumper->endId = $this->pageId4 + 1;
267 $dumper->reporting =
false;
268 $dumper->setDB( $this->db );
271 $dumper->dump( WikiExporter::CURRENT, WikiExporter::STUB );
278 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
279 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
280 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
284 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
285 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
286 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
295 $this->talk_namespace,
296 $this->pageTitle4->getPrefixedText()
298 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
299 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
323 $dumper =
new DumpBackup( [
"--full",
"--stub",
"--output=gzip:" . $fnameMetaHistory,
324 "--output=gzip:" . $fnameMetaCurrent,
"--filter=latest",
325 "--output=gzip:" . $fnameArticles,
"--filter=latest",
326 "--filter=notalk",
"--filter=namespace:!NS_USER",
327 "--reporting=1000" ] );
329 $dumper->endId = $this->pageId4 + 1;
330 $dumper->setDB( $this->db );
336 $dumper->stderr = fopen(
'php://output',
'a' );
337 if ( $dumper->stderr ===
false ) {
338 $this->fail(
"Could not open stream for stderr" );
342 $dumper->dump( WikiExporter::FULL, WikiExporter::STUB );
344 $this->assertTrue( fclose( $dumper->stderr ),
"Closing stderr handle" );
348 $this->
gunzip( $fnameMetaHistory );
352 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
353 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
354 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
358 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
359 $this->
assertRevision( $this->revId2_1,
"BackupDumperTestP2Summary1",
360 $this->textId2_1, 23,
"jprywrymfhysqllua29tj3sc7z39dl2" );
361 $this->
assertRevision( $this->revId2_2,
"BackupDumperTestP2Summary2",
362 $this->textId2_2, 23,
"b7vj5ks32po5m1z1t1br4o7scdwwy95",
false, $this->revId2_1 );
363 $this->
assertRevision( $this->revId2_3,
"BackupDumperTestP2Summary3",
364 $this->textId2_3, 23,
"jfunqmh1ssfb8rs43r19w98k28gg56r",
false, $this->revId2_2 );
365 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
366 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
375 $this->talk_namespace,
376 $this->pageTitle4->getPrefixedText()
378 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
379 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
386 $this->
gunzip( $fnameMetaCurrent );
390 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
391 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
392 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
396 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
397 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
398 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
407 $this->talk_namespace,
408 $this->pageTitle4->getPrefixedText()
410 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
411 $this->textId4_1, 35,
"nktofwzd0tl192k3zfepmlzxoax1lpe" );
418 $this->
gunzip( $fnameArticles );
422 $this->
assertPageStart( $this->pageId1, $this->
namespace, $this->pageTitle1->getPrefixedText() );
423 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
424 $this->textId1_1, 23,
"0bolhl6ol7i6x0e7yq91gxgaan39j87" );
428 $this->
assertPageStart( $this->pageId2, $this->
namespace, $this->pageTitle2->getPrefixedText() );
429 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
430 $this->textId2_4, 44,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
false, $this->revId2_3 );
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Internationalisation code.
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