X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fexport%2FXmlDumpWriter.php;h=39153cf7c0b69988f8fb2eb63c5fcd2409296ce1;hb=2e1ac38485b9c78890944413cba074474c06bd34;hp=6ca8853ca6da062605ba0bff67f56f8ce2b3cb4b;hpb=28b8d632ad487182c1f65c32dad9e921f80ccd02;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/export/XmlDumpWriter.php b/includes/export/XmlDumpWriter.php index 6ca8853ca6..39153cf7c0 100644 --- a/includes/export/XmlDumpWriter.php +++ b/includes/export/XmlDumpWriter.php @@ -141,6 +141,7 @@ class XmlDumpWriter { */ function namespaces() { $spaces = "\n"; + $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo(); foreach ( MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces() as $ns => $title @@ -149,7 +150,8 @@ class XmlDumpWriter { Xml::element( 'namespace', [ 'key' => $ns, - 'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive', + 'case' => $nsInfo->isCapitalized( $ns ) + ? 'first-letter' : 'case-sensitive', ], $title ) . "\n"; } $spaces .= " "; @@ -207,6 +209,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 " \n"; } @@ -289,8 +297,13 @@ class XmlDumpWriter { try { $text = $content_handler->exportTransform( $text, $content_format ); } - catch ( MWException $ex ) { - // leave text as is; that's the way it goes + catch ( Exception $ex ) { + if ( $ex instanceof MWException || $ex instanceof RuntimeException ) { + // leave text as is; that's the way it goes + wfLogWarning( 'exportTransform failed on text for revid ' . $row->rev_id . "\n" ); + } else { + throw $ex; + } } $out .= " " . Xml::elementClean( 'text', [ 'xml:space' => 'preserve', 'bytes' => intval( $row->rev_len ) ], @@ -299,21 +312,33 @@ class XmlDumpWriter { // TODO: make this fully MCR aware, see T174031 $rev = $this->getRevisionStore()->newRevisionFromRow( $row, 0, $this->currentTitle ); $slot = $rev->getSlot( 'main' ); - $content = $slot->getContent(); - - if ( $content instanceof TextContent ) { - // HACK: For text based models, bypass the serialization step. - // This allows extensions (like Flow)that use incompatible combinations - // of serialization format and content model. - $text = $content->getNativeData(); - } else { - $text = $content->serialize( $content_format ); + try { + $content = $slot->getContent(); + + if ( $content instanceof TextContent ) { + // HACK: For text based models, bypass the serialization step. + // This allows extensions (like Flow)that use incompatible combinations + // of serialization format and content model. + $text = $content->getNativeData(); + } else { + $text = $content->serialize( $content_format ); + } + $text = $content_handler->exportTransform( $text, $content_format ); + $out .= " " . Xml::elementClean( 'text', + [ 'xml:space' => 'preserve', 'bytes' => intval( $slot->getSize() ) ], + strval( $text ) ) . "\n"; + } + catch ( Exception $ex ) { + if ( $ex instanceof MWException || $ex instanceof RuntimeException ) { + // there's no provsion in the schema for an attribute that will let + // the user know this element was unavailable due to error; an empty + // tag is the best we can do + $out .= " " . Xml::element( 'text' ) . "\n"; + wfLogWarning( 'failed to load content for revid ' . $row->rev_id . "\n" ); + } else { + throw $ex; + } } - - $text = $content_handler->exportTransform( $text, $content_format ); - $out .= " " . Xml::elementClean( 'text', - [ 'xml:space' => 'preserve', 'bytes' => intval( $slot->getSize() ) ], - strval( $text ) ) . "\n"; } elseif ( isset( $row->rev_text_id ) ) { // Stub output for pre-MCR schema // TODO: MCR: rev_text_id only exists in the pre-MCR schema. Remove this when