Modernized slave wait checks in recompressTracked.php
[lhc/web/wiklou.git] / includes / Export.php
index 48a814d..adab21c 100644 (file)
@@ -69,7 +69,7 @@ class WikiExporter {
         * @return string
         */
        public static function schemaVersion() {
-               return "0.9";
+               return "0.10";
        }
 
        /**
@@ -213,7 +213,6 @@ class WikiExporter {
         * @param array $cond
         */
        protected function do_list_authors( $cond ) {
-               wfProfileIn( __METHOD__ );
                $this->author_list = "<contributors>";
                // rev_deleted
 
@@ -239,7 +238,6 @@ class WikiExporter {
                                "</contributor>";
                }
                $this->author_list .= "</contributors>";
-               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -248,7 +246,6 @@ class WikiExporter {
         * @throws Exception
         */
        protected function dumpFrom( $cond = '' ) {
-               wfProfileIn( __METHOD__ );
                # For logging dumps...
                if ( $this->history & self::LOGS ) {
                        $where = array( 'user_id = log_user' );
@@ -267,7 +264,7 @@ class WikiExporter {
                        if ( $this->buffer == WikiExporter::STREAM ) {
                                $prev = $this->db->bufferResults( false );
                        }
-                       $wrapper = null; // Assuring $wrapper is not undefined, if exception occurs early
+                       $result = null; // Assuring $result is not undefined, if exception occurs early
                        try {
                                $result = $this->db->select( array( 'logging', 'user' ),
                                        array( "{$logging}.*", 'user_name' ), // grab the user name
@@ -275,8 +272,7 @@ class WikiExporter {
                                        __METHOD__,
                                        array( 'ORDER BY' => 'log_id', 'USE INDEX' => array( 'logging' => 'PRIMARY' ) )
                                );
-                               $wrapper = $this->db->resultObject( $result );
-                               $this->outputLogStream( $wrapper );
+                               $this->outputLogStream( $result );
                                if ( $this->buffer == WikiExporter::STREAM ) {
                                        $this->db->bufferResults( $prev );
                                }
@@ -286,8 +282,8 @@ class WikiExporter {
 
                                // Freeing result
                                try {
-                                       if ( $wrapper ) {
-                                               $wrapper->free();
+                                       if ( $result ) {
+                                               $result->free();
                                        }
                                } catch ( Exception $e2 ) {
                                        // Already in panic mode -> ignoring $e2 as $e has
@@ -305,7 +301,6 @@ class WikiExporter {
                                }
 
                                // Inform caller about problem
-                               wfProfileOut( __METHOD__ );
                                throw $e;
                        }
                # For page dumps...
@@ -349,8 +344,7 @@ class WikiExporter {
                                # Default JOIN, to be overridden...
                                $join['revision'] = array( 'INNER JOIN', 'page_id=rev_page AND page_latest=rev_id' );
                                # One, and only one hook should set this, and return false
-                               if ( wfRunHooks( 'WikiExporter::dumpStableQuery', array( &$tables, &$opts, &$join ) ) ) {
-                                       wfProfileOut( __METHOD__ );
+                               if ( Hooks::run( 'WikiExporter::dumpStableQuery', array( &$tables, &$opts, &$join ) ) ) {
                                        throw new MWException( __METHOD__ . " given invalid history dump type." );
                                }
                        } elseif ( $this->history & WikiExporter::RANGE ) {
@@ -359,7 +353,6 @@ class WikiExporter {
                                $opts['ORDER BY'] = array( 'rev_page ASC', 'rev_id ASC' );
                        } else {
                                # Unknown history specification parameter?
-                               wfProfileOut( __METHOD__ );
                                throw new MWException( __METHOD__ . " given invalid history dump type." );
                        }
                        # Query optimization hacks
@@ -377,16 +370,15 @@ class WikiExporter {
                                $prev = $this->db->bufferResults( false );
                        }
 
-                       $wrapper = null; // Assuring $wrapper is not undefined, if exception occurs early
+                       $result = null; // Assuring $result is not undefined, if exception occurs early
                        try {
-                               wfRunHooks( 'ModifyExportQuery',
+                               Hooks::run( 'ModifyExportQuery',
                                                array( $this->db, &$tables, &$cond, &$opts, &$join ) );
 
                                # Do the query!
                                $result = $this->db->select( $tables, '*', $cond, __METHOD__, $opts, $join );
-                               $wrapper = $this->db->resultObject( $result );
                                # Output dump results
-                               $this->outputPageStream( $wrapper );
+                               $this->outputPageStream( $result );
 
                                if ( $this->buffer == WikiExporter::STREAM ) {
                                        $this->db->bufferResults( $prev );
@@ -397,8 +389,8 @@ class WikiExporter {
 
                                // Freeing result
                                try {
-                                       if ( $wrapper ) {
-                                               $wrapper->free();
+                                       if ( $result ) {
+                                               $result->free();
                                        }
                                } catch ( Exception $e2 ) {
                                        // Already in panic mode -> ignoring $e2 as $e has
@@ -419,7 +411,6 @@ class WikiExporter {
                                throw $e;
                        }
                }
-               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -467,7 +458,7 @@ class WikiExporter {
        }
 
        /**
-        * @param array $resultset
+        * @param ResultWrapper $resultset
         */
        protected function outputLogStream( $resultset ) {
                foreach ( $resultset as $row ) {
@@ -481,16 +472,6 @@ class WikiExporter {
  * @ingroup Dump
  */
 class XmlDumpWriter {
-       /**
-        * Returns the export schema version.
-        * @deprecated since 1.20; use WikiExporter::schemaVersion() instead
-        * @return string
-        */
-       function schemaVersion() {
-               wfDeprecated( __METHOD__, '1.20' );
-               return WikiExporter::schemaVersion();
-       }
-
        /**
         * Opens the XML output stream's root "<mediawiki>" element.
         * This does not include an xml directive, so is safe to include
@@ -639,7 +620,7 @@ class XmlDumpWriter {
                                strval( $row->page_restrictions ) ) . "\n";
                }
 
-               wfRunHooks( 'XmlDumpWriterOpenPage', array( $this, &$out, $row, $title ) );
+               Hooks::run( 'XmlDumpWriterOpenPage', array( $this, &$out, $row, $title ) );
 
                return $out;
        }
@@ -663,7 +644,6 @@ class XmlDumpWriter {
         * @access private
         */
        function writeRevision( $row ) {
-               wfProfileIn( __METHOD__ );
 
                $out = "    <revision>\n";
                $out .= "      " . Xml::element( 'id', null, strval( $row->rev_id ) ) . "\n";
@@ -705,6 +685,9 @@ class XmlDumpWriter {
                        $content_format = $content_handler->getDefaultFormat();
                }
 
+               $out .= "      " . Xml::element( 'model', null, strval( $content_model ) ) . "\n";
+               $out .= "      " . Xml::element( 'format', null, strval( $content_format ) ) . "\n";
+
                $text = '';
                if ( isset( $row->rev_deleted ) && ( $row->rev_deleted & Revision::DELETED_TEXT ) ) {
                        $out .= "      " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
@@ -731,14 +714,10 @@ class XmlDumpWriter {
                        $out .= "      <sha1/>\n";
                }
 
-               $out .= "      " . Xml::element( 'model', null, strval( $content_model ) ) . "\n";
-               $out .= "      " . Xml::element( 'format', null, strval( $content_format ) ) . "\n";
-
-               wfRunHooks( 'XmlDumpWriterWriteRevision', array( &$this, &$out, $row, $text ) );
+               Hooks::run( 'XmlDumpWriterWriteRevision', array( &$this, &$out, $row, $text ) );
 
                $out .= "    </revision>\n";
 
-               wfProfileOut( __METHOD__ );
                return $out;
        }
 
@@ -751,7 +730,6 @@ class XmlDumpWriter {
         * @access private
         */
        function writeLogItem( $row ) {
-               wfProfileIn( __METHOD__ );
 
                $out = "  <logitem>\n";
                $out .= "    " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n";
@@ -785,7 +763,6 @@ class XmlDumpWriter {
 
                $out .= "  </logitem>\n";
 
-               wfProfileOut( __METHOD__ );
                return $out;
        }
 
@@ -897,7 +874,7 @@ class XmlDumpWriter {
                }
 
                global $wgContLang;
-               $prefix = str_replace( '_', ' ', $wgContLang->getNsText( $title->getNamespace() ) );
+               $prefix = $wgContLang->getFormattedNsText( $title->getNamespace() );
 
                if ( $prefix !== '' ) {
                        $prefix .= ':';
@@ -1214,7 +1191,7 @@ class Dump7ZipOutput extends DumpPipeOutput {
         * @return string
         */
        function setup7zCommand( $file ) {
-               $command = "7za a -bd -si " . wfEscapeShellArg( $file );
+               $command = "7za a -bd -si -mx=4 " . wfEscapeShellArg( $file );
                // Suppress annoying useless crap from p7zip
                // Unfortunately this could suppress real error messages too
                $command .= ' >' . wfGetNull() . ' 2>&1';