r81437 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81436‎ | r81437 | r81438 >
Date:01:25, 3 February 2011
Author:werdna
Status:ok (Comments)
Tags:
Comment:
Kill the XMLReader2 class in response to Tim's code review comments on r68587
Modified paths:
  • /trunk/phase3/includes/Import.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Import.php
@@ -40,7 +40,7 @@
4141 * Creates an ImportXMLReader drawing from the source provided
4242 */
4343 function __construct( $source ) {
44 - $this->reader = new XMLReader2();
 44+ $this->reader = new XMLReader();
4545
4646 stream_wrapper_register( 'uploadsource', 'UploadSourceAdapter' );
4747 $id = UploadSourceAdapter::registerSource( $source );
@@ -281,7 +281,23 @@
282282 * @access private
283283 */
284284 private function nodeContents() {
285 - return $this->reader->nodeContents();
 285+ if( $this->reader->isEmptyElement ) {
 286+ return "";
 287+ }
 288+ $buffer = "";
 289+ while( $this->reader->read() ) {
 290+ switch( $this->reader->nodeType ) {
 291+ case XmlReader::TEXT:
 292+ case XmlReader::SIGNIFICANT_WHITESPACE:
 293+ $buffer .= $this->reader->value;
 294+ break;
 295+ case XmlReader::END_ELEMENT:
 296+ return $buffer;
 297+ }
 298+ }
 299+
 300+ $this->reader->close();
 301+ return '';
286302 }
287303
288304 # --------------
@@ -344,7 +360,7 @@
345361 $tag = $this->reader->name;
346362 $type = $this->reader->nodeType;
347363
348 - if ( !wfRunHooks( 'ImportHandleToplevelXMLTag', $this->reader ) ) {
 364+ if ( !wfRunHooks( 'ImportHandleToplevelXMLTag', $this ) ) {
349365 // Do nothing
350366 } elseif ( $tag == 'mediawiki' && $type == XmlReader::END_ELEMENT ) {
351367 break;
@@ -399,7 +415,7 @@
400416 $tag = $this->reader->name;
401417
402418 if ( !wfRunHooks( 'ImportHandleLogItemXMLTag',
403 - $this->reader, $logInfo ) ) {
 419+ $this, $logInfo ) ) {
404420 // Do nothing
405421 } elseif ( in_array( $tag, $normalFields ) ) {
406422 $logInfo[$tag] = $this->nodeContents();
@@ -459,7 +475,7 @@
460476 if ( $badTitle ) {
461477 // The title is invalid, bail out of this page
462478 $skip = true;
463 - } elseif ( !wfRunHooks( 'ImportHandlePageXMLTag', array( $this->reader,
 479+ } elseif ( !wfRunHooks( 'ImportHandlePageXMLTag', array( $this,
464480 &$pageInfo ) ) ) {
465481 // Do nothing
466482 } elseif ( in_array( $tag, $normalFields ) ) {
@@ -507,7 +523,7 @@
508524
509525 $tag = $this->reader->name;
510526
511 - if ( !wfRunHooks( 'ImportHandleRevisionXMLTag', $this->reader,
 527+ if ( !wfRunHooks( 'ImportHandleRevisionXMLTag', $this,
512528 $pageInfo, $revisionInfo ) ) {
513529 // Do nothing
514530 } elseif ( in_array( $tag, $normalFields ) ) {
@@ -568,7 +584,7 @@
569585
570586 $tag = $this->reader->name;
571587
572 - if ( !wfRunHooks( 'ImportHandleUploadXMLTag', $this->reader,
 588+ if ( !wfRunHooks( 'ImportHandleUploadXMLTag', $this,
573589 $pageInfo ) ) {
574590 // Do nothing
575591 } elseif ( in_array( $tag, $normalFields ) ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r814491.17: MFT r81437, r81446, r81447catrope14:08, 3 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r68587Some import-related fixes for LiquidThreads dump importation.werdna21:03, 25 June 2010

Comments

#Comment by Catrope (talk | contribs)   13:58, 3 February 2011

Needs docs/hooks.txt updates

Status & tagging log