3 require_once __DIR__ .
"/../../../maintenance/dumpTextPass.php";
31 $this->tablesUsed[] =
'page';
32 $this->tablesUsed[] =
'revision';
33 $this->tablesUsed[] =
'text';
36 "BackupTextPassTestModel" =>
"BackupTextPassTestModelHandler"
46 "BackupDumperTestP1Text1",
"BackupDumperTestP1Summary1" );
47 $this->pageId1 =
$page->getId();
53 "BackupDumperTestP2Text1",
"BackupDumperTestP2Summary1" );
55 "BackupDumperTestP2Text2",
"BackupDumperTestP2Summary2" );
57 "BackupDumperTestP2Text3",
"BackupDumperTestP2Summary3" );
59 "BackupDumperTestP2Text4 some additional Text ",
60 "BackupDumperTestP2Summary4 extra " );
61 $this->pageId2 =
$page->getId();
67 "BackupDumperTestP3Text1",
"BackupDumperTestP2Summary1" );
69 "BackupDumperTestP3Text2",
"BackupDumperTestP2Summary2" );
70 $this->pageId3 =
$page->getId();
71 $page->doDeleteArticle(
"Testing ;)" );
78 throw new MWException(
"The default wikitext namespace is the talk namespace. "
79 .
" We can't currently deal with that." );
85 "Talk about BackupDumperTestP1 Text1",
86 "Talk BackupDumperTestP1 Summary1",
87 "BackupTextPassTestModel" );
88 $this->pageId4 =
$page->getId();
93 $this->exceptionFromAddDBData =
$e;
105 [ $this->pageId2, $this->pageId3, $this->pageId4 ],
106 [ $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ],
107 "Page ids increasing without holes" );
115 "--output=file:" . $nameFull ] );
116 $dumper->reporting =
false;
117 $dumper->setDB( $this->db );
127 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
128 $this->textId1_1,
false,
"0bolhl6ol7i6x0e7yq91gxgaan39j87",
129 "BackupDumperTestP1Text1" );
134 $this->
assertRevision( $this->revId2_1,
"BackupDumperTestP2Summary1",
135 $this->textId2_1,
false,
"jprywrymfhysqllua29tj3sc7z39dl2",
136 "BackupDumperTestP2Text1" );
137 $this->
assertRevision( $this->revId2_2,
"BackupDumperTestP2Summary2",
138 $this->textId2_2,
false,
"b7vj5ks32po5m1z1t1br4o7scdwwy95",
139 "BackupDumperTestP2Text2", $this->revId2_1 );
140 $this->
assertRevision( $this->revId2_3,
"BackupDumperTestP2Summary3",
141 $this->textId2_3,
false,
"jfunqmh1ssfb8rs43r19w98k28gg56r",
142 "BackupDumperTestP2Text3", $this->revId2_2 );
143 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
144 $this->textId2_4,
false,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
145 "BackupDumperTestP2Text4 some additional Text", $this->revId2_3 );
153 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
154 $this->textId4_1,
false,
"nktofwzd0tl192k3zfepmlzxoax1lpe",
155 "TALK ABOUT BACKUPDUMPERTESTP1 TEXT1",
157 "BackupTextPassTestModel",
172 $prefetchMock = $this->getMock(
'BaseDump', [
'prefetch' ], [],
'',
false );
173 $prefetchMock->expects( $this->exactly( 6 ) )
174 ->method(
'prefetch' )
175 ->will( $this->returnValueMap( $prefetchMap ) );
182 "--output=file:" . $nameFull ] );
184 $dumper->prefetch = $prefetchMock;
185 $dumper->reporting =
false;
186 $dumper->setDB( $this->db );
198 $this->
assertRevision( $this->revId1_1,
"BackupDumperTestP1Summary1",
199 $this->textId1_1,
false,
"0bolhl6ol7i6x0e7yq91gxgaan39j87",
200 "Prefetch_________1Text1" );
205 $this->
assertRevision( $this->revId2_1,
"BackupDumperTestP2Summary1",
206 $this->textId2_1,
false,
"jprywrymfhysqllua29tj3sc7z39dl2",
207 "BackupDumperTestP2Text1" );
208 $this->
assertRevision( $this->revId2_2,
"BackupDumperTestP2Summary2",
209 $this->textId2_2,
false,
"b7vj5ks32po5m1z1t1br4o7scdwwy95",
210 "BackupDumperTestP2Text2", $this->revId2_1 );
213 $this->
assertRevision( $this->revId2_3,
"BackupDumperTestP2Summary3",
214 $this->textId2_3,
false,
"jfunqmh1ssfb8rs43r19w98k28gg56r",
215 "Prefetch_________2Text3", $this->revId2_2 );
216 $this->
assertRevision( $this->revId2_4,
"BackupDumperTestP2Summary4 extra",
217 $this->textId2_4,
false,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
218 "BackupDumperTestP2Text4 some additional Text", $this->revId2_3 );
226 $this->
assertRevision( $this->revId4_1,
"Talk BackupDumperTestP1 Summary1",
227 $this->textId4_1,
false,
"nktofwzd0tl192k3zfepmlzxoax1lpe",
228 "TALK ABOUT BACKUPDUMPERTESTP1 TEXT1",
230 "BackupTextPassTestModel",
249 $stderr = fopen(
'php://output',
'a' );
250 if ( $stderr ===
false ) {
251 $this->fail(
"Could not open stream for stderr" );
259 $checkpointAfter = 0.5;
264 while ( $lastDuration < $minDuration ) {
269 "Creating temporary output directory " );
270 $this->
setUpStub( $nameStub, $iterations );
272 $dumper->loadWithArgv( [
"--stub=file:" . $nameStub,
273 "--output=" . $checkpointFormat .
":" . $nameOutputDir .
"/full",
275 "--buffersize=32768",
276 "--checkpointfile=checkpoint-%s-%s.xml.gz" ] );
277 $dumper->setDB( $this->db );
278 $dumper->maxTimeAllowed = $checkpointAfter;
279 $dumper->stderr = $stderr;
282 $ts_before = microtime(
true );
284 $ts_after = microtime(
true );
285 $lastDuration = $ts_after - $ts_before;
288 if ( $lastDuration < $minDuration ) {
289 $old_iterations = $iterations;
290 if ( $lastDuration > 0.2 ) {
292 $factor = ( $minDuration + 0.5 ) / $lastDuration;
293 if ( ( $factor > 1.1 ) && ( $factor < 100 ) ) {
295 $iterations = (int)( $iterations * $factor );
299 if ( $old_iterations == $iterations ) {
304 $this->assertLessThan( 50000, $iterations,
305 "Emergency stop against infinitely increasing iteration "
306 .
"count ( last duration: $lastDuration )" );
314 $files = scandir( $nameOutputDir );
315 $this->assertTrue( asort(
$files ),
"Sorting files in temporary directory" );
318 $checkpointFiles = 0;
322 for ( $i = 0; $i < $iterations; ) {
326 if ( !$fileOpened ) {
327 $this->assertNotEmpty(
$files,
"No more existing dump files, "
328 .
"but not yet all pages found" );
331 $this->assertNotEmpty(
$files,
"No more existing dump"
332 .
" files, but not yet all pages found" );
335 if ( $checkpointFormat ==
"gzip" ) {
344 switch ( $lookingForPage ) {
348 "BackupDumperTestP1" );
349 $this->
assertRevision( $this->revId1_1 + $i * self::$numOfRevs,
"BackupDumperTestP1Summary1",
350 $this->textId1_1,
false,
"0bolhl6ol7i6x0e7yq91gxgaan39j87",
351 "BackupDumperTestP1Text1" );
360 "BackupDumperTestP2" );
361 $this->
assertRevision( $this->revId2_1 + $i * self::$numOfRevs,
"BackupDumperTestP2Summary1",
362 $this->textId2_1,
false,
"jprywrymfhysqllua29tj3sc7z39dl2",
363 "BackupDumperTestP2Text1" );
364 $this->
assertRevision( $this->revId2_2 + $i * self::$numOfRevs,
"BackupDumperTestP2Summary2",
365 $this->textId2_2,
false,
"b7vj5ks32po5m1z1t1br4o7scdwwy95",
366 "BackupDumperTestP2Text2", $this->revId2_1 + $i * self::$numOfRevs );
367 $this->
assertRevision( $this->revId2_3 + $i * self::$numOfRevs,
"BackupDumperTestP2Summary3",
368 $this->textId2_3,
false,
"jfunqmh1ssfb8rs43r19w98k28gg56r",
369 "BackupDumperTestP2Text3", $this->revId2_2 + $i * self::$numOfRevs );
371 "BackupDumperTestP2Summary4 extra",
372 $this->textId2_4,
false,
"6o1ciaxa6pybnqprmungwofc4lv00wv",
373 "BackupDumperTestP2Text4 some additional Text",
374 $this->revId2_3 + $i * self::$numOfRevs );
383 "Talk:BackupDumperTestP1" );
385 "Talk BackupDumperTestP1 Summary1",
386 $this->textId4_1,
false,
"nktofwzd0tl192k3zfepmlzxoax1lpe",
387 "TALK ABOUT BACKUPDUMPERTESTP1 TEXT1",
389 "BackupTextPassTestModel",
400 $this->fail(
"Bad setting for lookingForPage ($lookingForPage)" );
404 if ( $this->xml->nodeType == XMLReader::END_ELEMENT
405 && $this->xml->name ==
"mediawiki"
413 $this->assertFalse( $fileOpened,
"Currently read file still open?" );
414 $this->assertEmpty(
$files,
"Remaining unchecked files" );
417 $this->assertGreaterThan(
420 "expected more than 1 checkpoint to have been created. "
421 .
"Checkpoint interval is $checkpointAfter seconds, maybe your computer is too fast?"
474 $header =
'<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.10/" '
475 .
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
476 .
'xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.10/ '
477 .
'http://www.mediawiki.org/xml/export-0.10.xsd" version="0.10" xml:lang="en">
479 <sitename>wikisvn</sitename>
480 <base>http://localhost/wiki-svn/index.php/Main_Page</base>
481 <generator>MediaWiki 1.21alpha</generator>
482 <case>first-letter</case>
484 <namespace key="-2" case="first-letter">Media</namespace>
485 <namespace key="-1" case="first-letter">Special</namespace>
486 <namespace key="0" case="first-letter" />
487 <namespace key="1" case="first-letter">Talk</namespace>
488 <namespace key="2" case="first-letter">User</namespace>
489 <namespace key="3" case="first-letter">User talk</namespace>
490 <namespace key="4" case="first-letter">Wikisvn</namespace>
491 <namespace key="5" case="first-letter">Wikisvn talk</namespace>
492 <namespace key="6" case="first-letter">File</namespace>
493 <namespace key="7" case="first-letter">File talk</namespace>
494 <namespace key="8" case="first-letter">MediaWiki</namespace>
495 <namespace key="9" case="first-letter">MediaWiki talk</namespace>
496 <namespace key="10" case="first-letter">Template</namespace>
497 <namespace key="11" case="first-letter">Template talk</namespace>
498 <namespace key="12" case="first-letter">Help</namespace>
499 <namespace key="13" case="first-letter">Help talk</namespace>
500 <namespace key="14" case="first-letter">Category</namespace>
501 <namespace key="15" case="first-letter">Category talk</namespace>
505 $tail =
'</mediawiki>
509 $iterations = intval( $iterations );
510 for ( $i = 0; $i < $iterations; $i++ ) {
513 <title>BackupDumperTestP1</title>
515 <id>' . ( $this->pageId1 + $i * self::$numOfPages ) .
'</id>
517 <id>' . ( $this->revId1_1 + $i * self::$numOfRevs ) .
'</id>
518 <timestamp>2012-04-01T16:46:05Z</timestamp>
522 <comment>BackupDumperTestP1Summary1</comment>
523 <model>wikitext</model>
524 <format>text/x-wiki</format>
525 <text id="' . $this->textId1_1 .
'" bytes="23" />
526 <sha1>0bolhl6ol7i6x0e7yq91gxgaan39j87</sha1>
531 <title>BackupDumperTestP2</title>
533 <id>' . ( $this->pageId2 + $i * self::$numOfPages ) .
'</id>
535 <id>' . ( $this->revId2_1 + $i * self::$numOfRevs ) .
'</id>
536 <timestamp>2012-04-01T16:46:05Z</timestamp>
540 <comment>BackupDumperTestP2Summary1</comment>
541 <model>wikitext</model>
542 <format>text/x-wiki</format>
543 <text id="' . $this->textId2_1 .
'" bytes="23" />
544 <sha1>jprywrymfhysqllua29tj3sc7z39dl2</sha1>
547 <id>' . ( $this->revId2_2 + $i * self::$numOfRevs ) .
'</id>
548 <parentid>' . ( $this->revId2_1 + $i * self::$numOfRevs ) .
'</parentid>
549 <timestamp>2012-04-01T16:46:05Z</timestamp>
553 <comment>BackupDumperTestP2Summary2</comment>
554 <model>wikitext</model>
555 <format>text/x-wiki</format>
556 <text id="' . $this->textId2_2 .
'" bytes="23" />
557 <sha1>b7vj5ks32po5m1z1t1br4o7scdwwy95</sha1>
560 <id>' . ( $this->revId2_3 + $i * self::$numOfRevs ) .
'</id>
561 <parentid>' . ( $this->revId2_2 + $i * self::$numOfRevs ) .
'</parentid>
562 <timestamp>2012-04-01T16:46:05Z</timestamp>
566 <comment>BackupDumperTestP2Summary3</comment>
567 <model>wikitext</model>
568 <format>text/x-wiki</format>
569 <text id="' . $this->textId2_3 .
'" bytes="23" />
570 <sha1>jfunqmh1ssfb8rs43r19w98k28gg56r</sha1>
573 <id>' . ( $this->revId2_4 + $i * self::$numOfRevs ) .
'</id>
574 <parentid>' . ( $this->revId2_3 + $i * self::$numOfRevs ) .
'</parentid>
575 <timestamp>2012-04-01T16:46:05Z</timestamp>
579 <comment>BackupDumperTestP2Summary4 extra</comment>
580 <model>wikitext</model>
581 <format>text/x-wiki</format>
582 <text id="' . $this->textId2_4 .
'" bytes="44" />
583 <sha1>6o1ciaxa6pybnqprmungwofc4lv00wv</sha1>
590 <title>Talk:BackupDumperTestP1</title>
592 <id>' . ( $this->pageId4 + $i * self::$numOfPages ) .
'</id>
594 <id>' . ( $this->revId4_1 + $i * self::$numOfRevs ) .
'</id>
595 <timestamp>2012-04-01T16:46:05Z</timestamp>
599 <comment>Talk BackupDumperTestP1 Summary1</comment>
600 <model>BackupTextPassTestModel</model>
601 <format>text/plain</format>
602 <text id="' . $this->textId4_1 .
'" bytes="35" />
603 <sha1>nktofwzd0tl192k3zfepmlzxoax1lpe</sha1>
607 $content .= $page1 . $page2 . $page4;
610 $this->assertEquals( strlen(
$content ), file_put_contents(
620 parent::__construct(
'BackupTextPassTestModel' );
624 return strtoupper( $text );
646 $dumper->loadWithArgv( [
"--buffersize=" . $size ] );
648 $this->assertEquals( $expected, $dumper->getBufferSize(), $msg );
659 [ 512 * 1024, 512 * 1024,
"Setting 512KB is not effective" ],
660 [ 8192, 8192,
"Setting 8KB is not effective" ],
661 [ 4096, 2048,
"Could set buffer size below lower bound" ]
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
Accessor for internal state of TextPassDumper.
testCheckpointPlain()
Broken per T70653.
wfMkdirParents($dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
assertDumpEnd($name="mediawiki")
Asserts that the xml reader is at the final closing tag of an xml file and closes the reader...
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
bufferSizeProvider()
Ensures that setting the buffer size is effective.
assertPageStart($id, $ns, $name)
Asserts that the xml reader is at the start of a page element and skips over the first tags...
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
dump($history, $text=null)
addRevision(Page $page, $text, $summary, $model=CONTENT_MODEL_WIKITEXT)
Adds a revision to a page, while returning the resuting revision's id.
Tests for TextPassDumper that rely on the database.
exportTransform($text, $format=null)
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.
getBufferSize()
Gets the bufferSize.
namespace and then decline to actually register it file or subcat img or subcat $title
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...
testCheckpointGzip()
tests for working checkpoint generation in gzip format work.
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
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
checkpointHelper($checkpointFormat="file")
Ensures that checkpoint dumps are used and written, by successively increasing the stub size and dump...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
Base content handler implementation for flat text contents.
wfRecursiveRemoveDir($dir)
Remove a directory and all its content.
checkHasGzip()
Skip the test if 'gzip' is not in $PATH.
testBufferSizeSetting($expected, $size, $msg)
Ensures that setting the buffer size is effective.
setUpStub($fname=null, $iterations=1)
Creates a stub file that is used for testing the text pass of dumps.
expectETAOutput()
Checks for test output consisting only of lines containing ETA announcements.
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
assertPageEnd()
Asserts that the xml reader is at the page's closing element and skips to the next element...
Tests for TextPassDumper that do not rely on the database.