From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- maintenance/importDump.php | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'maintenance/importDump.php') diff --git a/maintenance/importDump.php b/maintenance/importDump.php index 1f47cf12..1f75bccf 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -3,7 +3,7 @@ * Import XML dump files into the current wiki. * * Copyright © 2005 Brion Vibber - * http://www.mediawiki.org/ + * https://www.mediawiki.org/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,8 +42,12 @@ class BackupReader extends Maintenance { function __construct() { parent::__construct(); - $gz = in_array( 'compress.zlib', stream_get_wrappers() ) ? 'ok' : '(disabled; requires PHP zlib module)'; - $bz2 = in_array( 'compress.bzip2', stream_get_wrappers() ) ? 'ok' : '(disabled; requires PHP bzip2 module)'; + $gz = in_array( 'compress.zlib', stream_get_wrappers() ) + ? 'ok' + : '(disabled; requires PHP zlib module)'; + $bz2 = in_array( 'compress.bzip2', stream_get_wrappers() ) + ? 'ok' + : '(disabled; requires PHP bzip2 module)'; $this->mDescription = << + TEXT; $this->stderr = fopen( "php://stderr", "wt" ); $this->addOption( 'report', @@ -67,7 +71,10 @@ TEXT; $this->addOption( 'dry-run', 'Parse dump without actually importing pages' ); $this->addOption( 'debug', 'Output extra verbose debug information' ); $this->addOption( 'uploads', 'Process file upload data if included (experimental)' ); - $this->addOption( 'no-updates', 'Disable link table updates. Is faster but leaves the wiki in an inconsistent state' ); + $this->addOption( + 'no-updates', + 'Disable link table updates. Is faster but leaves the wiki in an inconsistent state' + ); $this->addOption( 'image-base-path', 'Import files from a specified path', false, true ); $this->addArg( 'file', 'Dump file to import [else use stdin]', false ); } @@ -104,6 +111,7 @@ TEXT; function setNsfilter( array $namespaces ) { if ( count( $namespaces ) == 0 ) { $this->nsFilter = false; + return; } $this->nsFilter = array_unique( array_map( array( $this, 'getNsIndex' ), $namespaces ) ); @@ -122,7 +130,7 @@ TEXT; } /** - * @param $obj Title|Revision + * @param Title|Revision $obj * @return bool */ private function skippedNamespace( $obj ) { @@ -133,9 +141,9 @@ TEXT; } elseif ( $obj instanceof WikiRevision ) { $ns = $obj->title->getNamespace(); } else { - echo wfBacktrace(); - $this->error( "Cannot get namespace of object in " . __METHOD__, true ); + throw new MWException( "Cannot get namespace of object in " . __METHOD__ ); } + return is_array( $this->nsFilter ) && !in_array( $ns, $this->nsFilter ); } @@ -144,13 +152,13 @@ TEXT; } /** - * @param $rev Revision - * @return mixed + * @param Revision $rev */ function handleRevision( $rev ) { $title = $rev->getTitle(); if ( !$title ) { $this->progress( "Got bogus revision with null title!" ); + return; } @@ -167,13 +175,13 @@ TEXT; } /** - * @param $revision Revision + * @param Revision $revision * @return bool */ function handleUpload( $revision ) { if ( $this->uploads ) { if ( $this->skippedNamespace( $revision ) ) { - return; + return false; } $this->uploadCount++; // $this->report(); @@ -183,9 +191,12 @@ TEXT; // bluuuh hack // call_user_func( $this->uploadCallback, $revision ); $dbw = wfGetDB( DB_MASTER ); + return $dbw->deadlockLoop( array( $revision, 'importUpload' ) ); } } + + return false; } function handleLogItem( $rev ) { @@ -242,6 +253,7 @@ TEXT; } $file = fopen( $filename, 'rt' ); + return $this->importFromHandle( $file ); } @@ -250,6 +262,7 @@ TEXT; if ( self::posix_isatty( $file ) ) { $this->maybeHelp( true ); } + return $this->importFromHandle( $file ); } -- cgit v1.2.2