Merge "Added a separate error message for mkdir failures"
[lhc/web/wiklou.git] / includes / export / WikiExporter.php
index c1f2d59..943aa04 100644 (file)
@@ -27,6 +27,9 @@
  * @defgroup Dump Dump
  */
 
+use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IDatabase;
+
 /**
  * @ingroup SpecialPage Dump
  */
@@ -88,8 +91,8 @@ class WikiExporter {
         * @param int $buffer One of WikiExporter::BUFFER or WikiExporter::STREAM
         * @param int $text One of WikiExporter::TEXT or WikiExporter::STUB
         */
-       function __construct( $db, $history = WikiExporter::CURRENT,
-                       $buffer = WikiExporter::BUFFER, $text = WikiExporter::TEXT ) {
+       function __construct( $db, $history = self::CURRENT,
+                       $buffer = self::BUFFER, $text = self::TEXT ) {
                $this->db = $db;
                $this->history = $history;
                $this->buffer = $buffer;
@@ -269,7 +272,7 @@ class WikiExporter {
                        # Get logging table name for logging.* clause
                        $logging = $this->db->tableName( 'logging' );
 
-                       if ( $this->buffer == WikiExporter::STREAM ) {
+                       if ( $this->buffer == self::STREAM ) {
                                $prev = $this->db->bufferResults( false );
                        }
                        $result = null; // Assuring $result is not undefined, if exception occurs early
@@ -281,7 +284,7 @@ class WikiExporter {
                                        [ 'ORDER BY' => 'log_id', 'USE INDEX' => [ 'logging' => 'PRIMARY' ] ]
                                );
                                $this->outputLogStream( $result );
-                               if ( $this->buffer == WikiExporter::STREAM ) {
+                               if ( $this->buffer == self::STREAM ) {
                                        $this->db->bufferResults( $prev );
                                }
                        } catch ( Exception $e ) {
@@ -300,7 +303,7 @@ class WikiExporter {
 
                                // Putting database back in previous buffer mode
                                try {
-                                       if ( $this->buffer == WikiExporter::STREAM ) {
+                                       if ( $this->buffer == self::STREAM ) {
                                                $this->db->bufferResults( $prev );
                                        }
                                } catch ( Exception $e2 ) {
@@ -338,25 +341,25 @@ class WikiExporter {
                                if ( !empty( $this->history['limit'] ) ) {
                                        $opts['LIMIT'] = intval( $this->history['limit'] );
                                }
-                       } elseif ( $this->history & WikiExporter::FULL ) {
+                       } elseif ( $this->history & self::FULL ) {
                                # Full history dumps...
                                # query optimization for history stub dumps
-                               if ( $this->text == WikiExporter::STUB && $orderRevs ) {
+                               if ( $this->text == self::STUB && $orderRevs ) {
                                        $tables = [ 'revision', 'page' ];
-                                       $opts[] = 'STRAIGHT_JOIN';
+                                       $opts[] = 'STRAIGHT_JOIN';
                                        $opts['ORDER BY'] = [ 'rev_page ASC', 'rev_id ASC' ];
                                        $opts['USE INDEX']['revision'] = 'rev_page_id';
                                        $join['page'] = [ 'INNER JOIN', 'rev_page=page_id' ];
                                } else {
                                        $join['revision'] = [ 'INNER JOIN', 'page_id=rev_page' ];
                                }
-                       } elseif ( $this->history & WikiExporter::CURRENT ) {
+                       } elseif ( $this->history & self::CURRENT ) {
                                # Latest revision dumps...
                                if ( $this->list_authors && $cond != '' ) { // List authors, if so desired
                                        $this->do_list_authors( $cond );
                                }
                                $join['revision'] = [ 'INNER JOIN', 'page_id=rev_page AND page_latest=rev_id' ];
-                       } elseif ( $this->history & WikiExporter::STABLE ) {
+                       } elseif ( $this->history & self::STABLE ) {
                                # "Stable" revision dumps...
                                # Default JOIN, to be overridden...
                                $join['revision'] = [ 'INNER JOIN', 'page_id=rev_page AND page_latest=rev_id' ];
@@ -364,7 +367,7 @@ class WikiExporter {
                                if ( Hooks::run( 'WikiExporter::dumpStableQuery', [ &$tables, &$opts, &$join ] ) ) {
                                        throw new MWException( __METHOD__ . " given invalid history dump type." );
                                }
-                       } elseif ( $this->history & WikiExporter::RANGE ) {
+                       } elseif ( $this->history & self::RANGE ) {
                                # Dump of revisions within a specified range
                                $join['revision'] = [ 'INNER JOIN', 'page_id=rev_page' ];
                                $opts['ORDER BY'] = [ 'rev_page ASC', 'rev_id ASC' ];
@@ -378,12 +381,12 @@ class WikiExporter {
                                $opts['USE INDEX']['page'] = 'PRIMARY';
                        }
                        # Build text join options
-                       if ( $this->text != WikiExporter::STUB ) { // 1-pass
+                       if ( $this->text != self::STUB ) { // 1-pass
                                $tables[] = 'text';
                                $join['text'] = [ 'INNER JOIN', 'rev_text_id=old_id' ];
                        }
 
-                       if ( $this->buffer == WikiExporter::STREAM ) {
+                       if ( $this->buffer == self::STREAM ) {
                                $prev = $this->db->bufferResults( false );
                        }
                        $result = null; // Assuring $result is not undefined, if exception occurs early
@@ -396,7 +399,7 @@ class WikiExporter {
                                # Output dump results
                                $this->outputPageStream( $result );
 
-                               if ( $this->buffer == WikiExporter::STREAM ) {
+                               if ( $this->buffer == self::STREAM ) {
                                        $this->db->bufferResults( $prev );
                                }
                        } catch ( Exception $e ) {
@@ -415,7 +418,7 @@ class WikiExporter {
 
                                // Putting database back in previous buffer mode
                                try {
-                                       if ( $this->buffer == WikiExporter::STREAM ) {
+                                       if ( $this->buffer == self::STREAM ) {
                                                $this->db->bufferResults( $prev );
                                        }
                                } catch ( Exception $e2 ) {