avoid link cache issues with duplicate title keys for xml dumps
[lhc/web/wiklou.git] / includes / export / XmlDumpWriter.php
index 3c0b569..2ae5c2f 100644 (file)
@@ -207,6 +207,12 @@ class XmlDumpWriter {
         * @return string
         */
        function closePage() {
+               if ( $this->currentTitle !== null ) {
+                       $linkCache = MediaWikiServices::getInstance()->getLinkCache();
+                       // In rare cases, link cache has the same key for some pages which
+                       // might be read as part of the same batch. T220424 and T220316
+                       $linkCache->clearLink( $this->currentTitle );
+               }
                return "  </page>\n";
        }
 
@@ -286,7 +292,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";