Revert "(bug 24620) Add types to LogFormatter"
[lhc/web/wiklou.git] / maintenance / backupTextPass.inc
index 11f0cd5..81e61b7 100644 (file)
@@ -24,6 +24,7 @@
  * @ingroup Maintenance
  */
 
+require_once( __DIR__ . '/backup.inc' );
 
 /**
  * @ingroup Maintenance
@@ -168,11 +169,7 @@ class TextPassDumper extends BackupDumper {
                $this->xmlwriterobj = new XmlDumpWriter();
 
                $input = fopen( $this->input, "rt" );
-               $result = $this->readDump( $input );
-
-               if ( WikiError::isError( $result ) ) {
-                       throw new MWException( $result->getMessage() );
-               }
+               $this->readDump( $input );
 
                if ( $this->spawnProc ) {
                        $this->closeSpawn();
@@ -250,9 +247,9 @@ class TextPassDumper extends BackupDumper {
 
                if ( $this->reporting ) {
                        $now = wfTimestamp( TS_DB );
-                       $nowts = wfTime();
-                       $deltaAll = wfTime() - $this->startTime;
-                       $deltaPart = wfTime() - $this->lastTime;
+                       $nowts = microtime( true );
+                       $deltaAll = $nowts - $this->startTime;
+                       $deltaPart = $nowts - $this->lastTime;
                        $this->pageCountPart = $this->pageCount - $this->pageCountLast;
                        $this->revCountPart = $this->revCount - $this->revCountLast;
 
@@ -327,6 +324,10 @@ class TextPassDumper extends BackupDumper {
                }
        }
 
+       /**
+        * @throws MWException Failure to parse XML input
+        * @return true
+        */
        function readDump( $input ) {
                $this->buffer = "";
                $this->openElement = false;
@@ -351,7 +352,18 @@ class TextPassDumper extends BackupDumper {
                        $chunk = fread( $input, $bufferSize );
                        if ( !xml_parse( $parser, $chunk, feof( $input ) ) ) {
                                wfDebug( "TextDumpPass::readDump encountered XML parsing error\n" );
-                               return new WikiXmlError( $parser, 'XML import parse failure', $chunk, $offset );
+
+                               $byte = xml_get_current_byte_index( $parser );
+                               $msg = wfMessage( 'xml-error-string',
+                                       'XML import parse failure',
+                                       xml_get_current_line_number( $parser ),
+                                       xml_get_current_column_number( $parser ),
+                                       $byte . ( is_null( $chunk ) ? null : ( '; "' . substr( $chunk, $byte -$offset, 16 ) . '"' ) ),
+                                       xml_error_string( xml_get_error_code( $parser ) ) )->escaped();
+
+                               xml_parser_free( $parser );
+
+                               throw new MWException( $msg );
                        }
                        $offset += strlen( $chunk );
                } while ( $chunk !== false && !feof( $input ) );
@@ -430,7 +442,8 @@ class TextPassDumper extends BackupDumper {
                                if ( $text === false && isset( $this->prefetch ) && $prefetchNotTried ) {
                                        $prefetchNotTried = false;
                                        $tryIsPrefetch = true;
-                                       $text = $this->prefetch->prefetch( $this->thisPage, $this->thisRev );
+                                       $text = $this->prefetch->prefetch( intval( $this->thisPage ),
+                                               intval( $this->thisRev ) );
                                        if ( $text === null ) {
                                                $text = false;
                                        }