From afa123ccf886ed4546df56c0348d16e557124f6e Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 9 Jun 2012 15:41:55 +0200 Subject: [PATCH] (bug 33222) Add parentid to revision in export xml From bug description: "This is helpful for incremental dumps, to know if there are revisions missing between the last full dump and this incremental dump" Change-Id: I772f976942a306ad573efc659d09714e8250f5ec --- docs/export-0.7.xsd | 2 ++ docs/export-demo.xml | 2 ++ includes/Export.php | 3 +++ tests/phpunit/maintenance/DumpTestCase.php | 6 ++++- .../maintenance/backupPrefetchTest.php | 1 + .../maintenance/backupTextPassTest.php | 21 ++++++++------- tests/phpunit/maintenance/backup_PageTest.php | 26 +++++++++---------- 7 files changed, 38 insertions(+), 23 deletions(-) diff --git a/docs/export-0.7.xsd b/docs/export-0.7.xsd index 6a4a8b7f6a..6d02328689 100644 --- a/docs/export-0.7.xsd +++ b/docs/export-0.7.xsd @@ -22,6 +22,7 @@ revision identifiers. See also bug 4220. Fix type for from "positiveInteger" to "nonNegativeInteger" to allow 0 Moves to its right location. + Add parentid to revision. The canonical URL to the schema document is: http://www.mediawiki.org/xml/export-0.7.xsd @@ -158,6 +159,7 @@ + diff --git a/docs/export-demo.xml b/docs/export-demo.xml index b28022f742..d198b93c8a 100644 --- a/docs/export-demo.xml +++ b/docs/export-demo.xml @@ -70,6 +70,8 @@ 100 + + 99 2001-01-15T13:15:00Z Foobar diff --git a/includes/Export.php b/includes/Export.php index 6c47e341fd..aa571f4178 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -626,6 +626,9 @@ class XmlDumpWriter { $out = " \n"; $out .= " " . Xml::element( 'id', null, strval( $row->rev_id ) ) . "\n"; + if( $row->rev_parent_id ) { + $out .= " " . Xml::element( 'parentid', null, strval( $row->rev_parent_id ) ) . "\n"; + } $out .= $this->writeTimestamp( $row->rev_timestamp ); diff --git a/tests/phpunit/maintenance/DumpTestCase.php b/tests/phpunit/maintenance/DumpTestCase.php index 976fd6bed5..e71e76c7d5 100644 --- a/tests/phpunit/maintenance/DumpTestCase.php +++ b/tests/phpunit/maintenance/DumpTestCase.php @@ -295,13 +295,17 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { * @param $text_sha1 string: the base36 SHA-1 of the revision's text * @param $text string|false: (optional) The revision's string, or false to check for a * revision stub + * @param $parentid int|false: (optional) id of the parent revision */ - protected function assertRevision( $id, $summary, $text_id, $text_bytes, $text_sha1, $text = false ) { + protected function assertRevision( $id, $summary, $text_id, $text_bytes, $text_sha1, $text = false, $parentid = false ) { $this->assertNodeStart( "revision" ); $this->skipWhitespace(); $this->assertTextNode( "id", $id ); + if( $parentid ) { + $this->assertTextNode( "parentid", $parentid ); + } $this->assertTextNode( "timestamp", false ); $this->assertNodeStart( "contributor" ); diff --git a/tests/phpunit/maintenance/backupPrefetchTest.php b/tests/phpunit/maintenance/backupPrefetchTest.php index 9273233b1d..01ee4ee3e7 100644 --- a/tests/phpunit/maintenance/backupPrefetchTest.php +++ b/tests/phpunit/maintenance/backupPrefetchTest.php @@ -207,6 +207,7 @@ class BaseDumpTest extends MediaWikiTestCase { 2 2 + 5 2012-04-01T16:46:05Z 127.0.0.1 diff --git a/tests/phpunit/maintenance/backupTextPassTest.php b/tests/phpunit/maintenance/backupTextPassTest.php index 0d7f155f3f..edcd83423a 100644 --- a/tests/phpunit/maintenance/backupTextPassTest.php +++ b/tests/phpunit/maintenance/backupTextPassTest.php @@ -113,13 +113,13 @@ class TextPassDumperTest extends DumpTestCase { $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" ); $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1", $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2", - "BackupDumperTestP2Text1" ); + "BackupDumperTestP2Text1", $this->revId2_2 ); $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2", $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95", - "BackupDumperTestP2Text2" ); + "BackupDumperTestP2Text2", $this->revId2_3 ); $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3", $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r", - "BackupDumperTestP2Text3" ); + "BackupDumperTestP2Text3", $this->revId2_4 ); $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv", "BackupDumperTestP2Text4 some additional Text" ); @@ -179,15 +179,15 @@ class TextPassDumperTest extends DumpTestCase { $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" ); $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1", $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2", - "BackupDumperTestP2Text1" ); + "BackupDumperTestP2Text1", $this->revId2_2 ); $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2", $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95", - "BackupDumperTestP2Text2" ); + "BackupDumperTestP2Text2", $this->revId2_3 ); // Prefetch kicks in. This is still the SHA-1 of the original text, // But the actual text (with different SHA-1) comes from prefetch. $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3", $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r", - "Prefetch_________2Text3" ); + "Prefetch_________2Text3", $this->revId2_4 ); $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv", "BackupDumperTestP2Text4 some additional Text" ); @@ -331,13 +331,13 @@ class TextPassDumperTest extends DumpTestCase { "BackupDumperTestP2" ); $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1", $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2", - "BackupDumperTestP2Text1" ); + "BackupDumperTestP2Text1", $this->revId2_2 ); $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2", $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95", - "BackupDumperTestP2Text2" ); + "BackupDumperTestP2Text2", $this->revId2_3 ); $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3", $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r", - "BackupDumperTestP2Text3" ); + "BackupDumperTestP2Text3", $this->revId2_4 ); $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv", @@ -489,6 +489,7 @@ class TextPassDumperTest extends DumpTestCase { ' . ( $this->pageId2 + $i * 4 ) . ' ' . $this->revId2_1 . ' + ' . $this->revId2_2 . ' 2012-04-01T16:46:05Z 127.0.0.1 @@ -499,6 +500,7 @@ class TextPassDumperTest extends DumpTestCase { ' . $this->revId2_2 . ' + ' . $this->revId2_3 . ' 2012-04-01T16:46:05Z 127.0.0.1 @@ -509,6 +511,7 @@ class TextPassDumperTest extends DumpTestCase { ' . $this->revId2_3 . ' + ' . $this->revId2_4 . ' 2012-04-01T16:46:05Z 127.0.0.1 diff --git a/tests/phpunit/maintenance/backup_PageTest.php b/tests/phpunit/maintenance/backup_PageTest.php index 3850c4a0f9..925e277d9d 100644 --- a/tests/phpunit/maintenance/backup_PageTest.php +++ b/tests/phpunit/maintenance/backup_PageTest.php @@ -108,13 +108,13 @@ class BackupDumperPageTest extends DumpTestCase { "BackupDumperTestP2Text1" ); $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2", $this->textId2_2, 23, "b7vj5ks32po5m1z1t1br4o7scdwwy95", - "BackupDumperTestP2Text2" ); + "BackupDumperTestP2Text2", $this->revId2_1 ); $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3", $this->textId2_3, 23, "jfunqmh1ssfb8rs43r19w98k28gg56r", - "BackupDumperTestP2Text3" ); + "BackupDumperTestP2Text3", $this->revId2_2 ); $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", - "BackupDumperTestP2Text4 some additional Text" ); + "BackupDumperTestP2Text4 some additional Text", $this->revId2_3 ); $this->assertPageEnd(); // Page 3 @@ -156,11 +156,11 @@ class BackupDumperPageTest extends DumpTestCase { $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1", $this->textId2_1, 23, "jprywrymfhysqllua29tj3sc7z39dl2" ); $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2", - $this->textId2_2, 23, "b7vj5ks32po5m1z1t1br4o7scdwwy95" ); + $this->textId2_2, 23, "b7vj5ks32po5m1z1t1br4o7scdwwy95", false, $this->revId2_1 ); $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3", - $this->textId2_3, 23, "jfunqmh1ssfb8rs43r19w98k28gg56r" ); + $this->textId2_3, 23, "jfunqmh1ssfb8rs43r19w98k28gg56r", false, $this->revId2_2 ); $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", - $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv" ); + $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", false, $this->revId2_3 ); $this->assertPageEnd(); // Page 3 @@ -199,7 +199,7 @@ class BackupDumperPageTest extends DumpTestCase { // Page 2 $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" ); $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", - $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv" ); + $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", false, $this->revId2_3 ); $this->assertPageEnd(); // Page 3 @@ -239,7 +239,7 @@ class BackupDumperPageTest extends DumpTestCase { // Page 2 $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" ); $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", - $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv" ); + $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", false, $this->revId2_3 ); $this->assertPageEnd(); // Page 3 @@ -310,11 +310,11 @@ class BackupDumperPageTest extends DumpTestCase { $this->assertRevision( $this->revId2_1, "BackupDumperTestP2Summary1", $this->textId2_1, 23, "jprywrymfhysqllua29tj3sc7z39dl2" ); $this->assertRevision( $this->revId2_2, "BackupDumperTestP2Summary2", - $this->textId2_2, 23, "b7vj5ks32po5m1z1t1br4o7scdwwy95" ); + $this->textId2_2, 23, "b7vj5ks32po5m1z1t1br4o7scdwwy95", false, $this->revId2_1 ); $this->assertRevision( $this->revId2_3, "BackupDumperTestP2Summary3", - $this->textId2_3, 23, "jfunqmh1ssfb8rs43r19w98k28gg56r" ); + $this->textId2_3, 23, "jfunqmh1ssfb8rs43r19w98k28gg56r", false, $this->revId2_2 ); $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", - $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv" ); + $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", false, $this->revId2_3 ); $this->assertPageEnd(); // Page 3 @@ -342,7 +342,7 @@ class BackupDumperPageTest extends DumpTestCase { // Page 2 $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" ); $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", - $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv" ); + $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", false, $this->revId2_3 ); $this->assertPageEnd(); // Page 3 @@ -370,7 +370,7 @@ class BackupDumperPageTest extends DumpTestCase { // Page 2 $this->assertPageStart( $this->pageId2, NS_MAIN, "BackupDumperTestP2" ); $this->assertRevision( $this->revId2_4, "BackupDumperTestP2Summary4 extra", - $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv" ); + $this->textId2_4, 44, "6o1ciaxa6pybnqprmungwofc4lv00wv", false, $this->revId2_3 ); $this->assertPageEnd(); // Page 3 -- 2.20.1