don't die producing xml files if rev text export conversion fails
authorAriel T. Glenn <ariel@wikimedia.org>
Wed, 13 Mar 2019 23:16:24 +0000 (01:16 +0200)
committerAriel T. Glenn <ariel@wikimedia.org>
Wed, 13 Mar 2019 23:16:24 +0000 (01:16 +0200)
In abstracts for the specific case, we don't care at all, since the
problem is that it's a self redirect. Redirects are filtered out of
the stream at the end so it won't even show up.

In anything else, we do what dumpTextPass does already, which is to
leave the text alone and emit it as is.

Bug: T217329
Change-Id: I39cdf89531c67962b1a9bba4e0a91f7c655ad6f3

includes/export/XmlDumpWriter.php

index fae8b62..5a44040 100644 (file)
@@ -254,7 +254,12 @@ class XmlDumpWriter {
                } elseif ( isset( $row->old_text ) ) {
                        // Raw text from the database may have invalid chars
                        $text = strval( Revision::getRevisionText( $row ) );
-                       $text = $content_handler->exportTransform( $text, $content_format );
+                       try {
+                               $text = $content_handler->exportTransform( $text, $content_format );
+                       }
+                       catch ( MWException $ex ) {
+                               // leave text as is; that's the way it goes
+                       }
                        $out .= "      " . Xml::elementClean( 'text',
                                [ 'xml:space' => 'preserve', 'bytes' => intval( $row->rev_len ) ],
                                strval( $text ) ) . "\n";