Brion VIBBER has submitted this change and it was merged.

Change subject: Support MediaWiki 1.25 schema
......................................................................


Support MediaWiki 1.25 schema

The page_counter column was dropped, and other properties became available with
the 0.10 version of the XML schema.

Bug: T120665
Change-Id: I33ccb873403b89c87eaf36486090b8c3b1ddf99d
---
M README
M src/org/mediawiki/dumper/Dumper.java
M src/org/mediawiki/importer/SqlWriter15.java
A src/org/mediawiki/importer/SqlWriter1_25.java
4 files changed, 104 insertions(+), 5 deletions(-)

Approvals:
  Brion VIBBER: Verified; Looks good to me, approved



diff --git a/README b/README
index 5788290..cf38b05 100644
--- a/README
+++ b/README
@@ -32,8 +32,8 @@
     --output=bzip2:pages_current.xml.bz2 \
       --format=xml \
       --filter=latest \
-    --output=gzip:pages_full_1.5.sql.gz \
-      --format=mysql:1.5 \
+    --output=gzip:pages_full_1.25.sql.gz \
+      --format=mysql:1.25 \
     --output=gzip:pages_full_1.4.sql.gz \
       --format=mysql:1.4 \
     pages_full.xml.gz
@@ -88,6 +88,8 @@
       be already set up in an empty database; use maintenance/tables.sql
       from the MediaWiki distribution.
       (MySQL output format.)
+  --format=mysql:1.25
+      SQL statements formatted for bulk import into MediaWiki 1.25's schema.
   --format=pgsql:1.4
       SQL statements formatted for bulk import in MediaWiki 1.4's schema.
       (PostgreSQL output format.)
diff --git a/src/org/mediawiki/dumper/Dumper.java 
b/src/org/mediawiki/dumper/Dumper.java
index 177f42a..4aa921e 100644
--- a/src/org/mediawiki/dumper/Dumper.java
+++ b/src/org/mediawiki/dumper/Dumper.java
@@ -261,6 +261,8 @@
                                ret = new SqlWriter14(tr, sqlStream);
                        else if (param.equals("1.5"))
                                ret = new SqlWriter15(tr, sqlStream);
+                       else if (param.equals("1.25"))
+                               ret = new SqlWriter1_25(tr, sqlStream);
                        else
                                throw new IllegalArgumentException("SQL version 
not known: " + param);
 
diff --git a/src/org/mediawiki/importer/SqlWriter15.java 
b/src/org/mediawiki/importer/SqlWriter15.java
index cd02773..f57473d 100644
--- a/src/org/mediawiki/importer/SqlWriter15.java
+++ b/src/org/mediawiki/importer/SqlWriter15.java
@@ -30,8 +30,8 @@
 import java.io.IOException;
 
 public class SqlWriter15 extends SqlWriter {
-       private Page currentPage;
-       private Revision lastRevision;
+       protected Page currentPage;
+       protected Revision lastRevision;
        
        public SqlWriter15(SqlWriter.Traits tr, SqlStream output) {
                super(tr, output);
@@ -89,7 +89,7 @@
                lastRevision = revision;
        }
        
-       private void updatePage(Page page, Revision revision) throws 
IOException {
+       protected void updatePage(Page page, Revision revision) throws 
IOException {
                bufferInsertRow("page", new Object[][] {
                                {"page_id", new Integer(page.Id)},
                                {"page_namespace", page.Title.Namespace},
diff --git a/src/org/mediawiki/importer/SqlWriter1_25.java 
b/src/org/mediawiki/importer/SqlWriter1_25.java
new file mode 100644
index 0000000..a24696c
--- /dev/null
+++ b/src/org/mediawiki/importer/SqlWriter1_25.java
@@ -0,0 +1,95 @@
+/*
+ * MediaWiki import/export processing tools
+ * Copyright 2005 by Brion Vibber
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE
+ * SOFTWARE.
+ *
+ * $Id$
+ */
+
+package org.mediawiki.importer;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+
+public class SqlWriter1_25 extends SqlWriter15 {
+       public SqlWriter1_25(SqlWriter.Traits tr, SqlStream output) {
+               super(tr, output);
+       }
+       
+       public SqlWriter1_25(SqlWriter.Traits tr, SqlStream output, String 
prefix) {
+               super(tr, output, prefix);
+       }
+       
+       protected void updatePage(Page page, Revision revision) throws 
IOException {
+               bufferInsertRow("page", new Object[][] {
+                               {"page_id", new Integer(page.Id)},
+                               {"page_namespace", page.Title.Namespace},
+                               {"page_title", titleFormat(page.Title.Text)},
+                               {"page_restrictions", page.Restrictions},
+                               {"page_is_redirect", page.isRedirect ? ONE : 
ZERO},
+                               {"page_is_new", ZERO},
+                               {"page_random", traits.getRandom()},
+                               {"page_touched", traits.getCurrentTime()},
+                               {"page_latest", new Integer(revision.Id)},
+                               {"page_len", revision.Bytes},
+                               {"page_content_model", revision.Model},
+               });
+
+               if (page.Redirect != null) {
+                       bufferInsertRow("redirect", new Object[][] {
+                               {"rd_from", new Integer(page.Id)},
+                               {"rd_namespace", page.Redirect.Namespace},
+                               {"rd_title", titleFormat(page.Redirect.Text)},
+                       });
+               }
+               checkpoint();
+       }
+
+       public void writeRevision(Revision revision) throws IOException {
+               bufferInsertRow(traits.getTextTable(), new Object[][] {
+                               {"old_id", new Integer(revision.Id)},
+                               {"old_text", revision.Text == null ? "" : 
revision.Text},
+                               {"old_flags", "utf-8"}});
+               
+               int rev_deleted = 0;
+               if (revision.Contributor.Username==null) rev_deleted |= 
DELETED_USER;
+               if (revision.Comment==null) rev_deleted |= DELETED_COMMENT;
+               if (revision.Text==null) rev_deleted |= DELETED_TEXT;
+
+               bufferInsertRow("revision", new Object[][] {
+                               {"rev_id", new Integer(revision.Id)},
+                               {"rev_page", new Integer(currentPage.Id)},
+                               {"rev_text_id", new Integer(revision.Id)},
+                               {"rev_comment", 
commentFormat(revision.Comment)},
+                               {"rev_user", revision.Contributor.Username == 
null ? ZERO :  new Integer(revision.Contributor.Id)},
+                               {"rev_user_text", revision.Contributor.Username 
== null ? "" : revision.Contributor.Username},
+                               {"rev_timestamp", 
timestampFormat(revision.Timestamp)},
+                               {"rev_minor_edit", revision.Minor ? ONE : ZERO},
+                               {"rev_parent_id", revision.Parentid == 0 ? null 
: new Integer(revision.Parentid)},
+                               {"rev_sha1", revision.Sha1},
+                               {"rev_content_model", revision.Model},
+                               {"rev_content_format", revision.Format},
+                               {"rev_deleted", rev_deleted==0 ? ZERO : new 
Integer(rev_deleted)},
+                               {"rev_len", revision.Bytes},
+               });
+               
+               lastRevision = revision;
+       }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/191555
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I33ccb873403b89c87eaf36486090b8c3b1ddf99d
Gerrit-PatchSet: 12
Gerrit-Project: mediawiki/tools/mwdumper
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
Gerrit-Reviewer: ArielGlenn <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Diederik <[email protected]>
Gerrit-Reviewer: Oren <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to