Merge "(bug 33222) Add parentid to revision in export xml"
authorAaron Schulz <aschulz@wikimedia.org>
Sat, 16 Jun 2012 04:25:52 +0000 (04:25 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 16 Jun 2012 04:25:52 +0000 (04:25 +0000)
docs/export-0.7.xsd
docs/export-demo.xml
includes/Export.php
tests/phpunit/maintenance/DumpTestCase.php
tests/phpunit/maintenance/backupPrefetchTest.php
tests/phpunit/maintenance/backupTextPassTest.php
tests/phpunit/maintenance/backup_PageTest.php

index 6a4a8b7..6d02328 100644 (file)
@@ -22,6 +22,7 @@
        revision identifiers. See also bug 4220.
        Fix type for <ns> from "positiveInteger" to "nonNegativeInteger" to allow 0
        Moves <logitem> 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
        <complexType name="RevisionType">
                <sequence>
                        <element name="id" type="positiveInteger" />
+                       <element name="parentid" type="positiveInteger" minOccurs="0" />
                        <element name="timestamp" type="dateTime" />
                        <element name="contributor" type="mw:ContributorType" />
                        <element name="minor" minOccurs="0" maxOccurs="1" />
index b28022f..d198b93 100644 (file)
@@ -70,6 +70,8 @@
       <!-- Unique revision ID number (rev_id) in the source database.  -->
       <!-- This number uniquely identifies the revision on that wiki.  -->
       <id>100</id>
+      <!-- revision id of the parent revision -->
+      <parentid>99</parentid>
       <timestamp>2001-01-15T13:15:00Z</timestamp>
       <contributor>
         <username>Foobar</username>
index 6c47e34..aa571f4 100644 (file)
@@ -626,6 +626,9 @@ class XmlDumpWriter {
 
                $out  = "    <revision>\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 );
 
index 976fd6b..e71e76c 100644 (file)
@@ -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" );
index 0d3f933..e92b289 100644 (file)
@@ -207,6 +207,7 @@ class BaseDumpTest extends MediaWikiTestCase {
     <id>2</id>
     <revision>
       <id>2</id>
+      <parentid>5</parentid>
       <timestamp>2012-04-01T16:46:05Z</timestamp>
       <contributor>
         <ip>127.0.0.1</ip>
index 413c6d0..6cdba85 100644 (file)
@@ -112,13 +112,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" );
@@ -178,15 +178,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" );
@@ -330,13 +330,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",
@@ -488,6 +488,7 @@ class TextPassDumperTest extends DumpTestCase {
     <id>' . ( $this->pageId2 + $i * 4 ) . '</id>
     <revision>
       <id>' . $this->revId2_1 . '</id>
+      <parentid>' . $this->revId2_2 . '</parentid>
       <timestamp>2012-04-01T16:46:05Z</timestamp>
       <contributor>
         <ip>127.0.0.1</ip>
@@ -498,6 +499,7 @@ class TextPassDumperTest extends DumpTestCase {
     </revision>
     <revision>
       <id>' . $this->revId2_2 . '</id>
+      <parentid>' . $this->revId2_3 . '</parentid>
       <timestamp>2012-04-01T16:46:05Z</timestamp>
       <contributor>
         <ip>127.0.0.1</ip>
@@ -508,6 +510,7 @@ class TextPassDumperTest extends DumpTestCase {
     </revision>
     <revision>
       <id>' . $this->revId2_3 . '</id>
+      <parentid>' . $this->revId2_4 . '</parentid>
       <timestamp>2012-04-01T16:46:05Z</timestamp>
       <contributor>
         <ip>127.0.0.1</ip>
index 3850c4a..925e277 100644 (file)
@@ -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