From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- includes/Export.php | 517 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 438 insertions(+), 79 deletions(-) (limited to 'includes/Export.php') diff --git a/includes/Export.php b/includes/Export.php index 7773d03c..f01fb237 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -49,6 +49,23 @@ class WikiExporter { const TEXT = 0; const STUB = 1; + var $buffer; + + var $text; + + /** + * @var DumpOutput + */ + var $sink; + + /** + * Returns the export schema version. + * @return string + */ + public static function schemaVersion() { + return "0.7"; + } + /** * If using WikiExporter::STREAM to stream a large amount of data, * provide a database connection which is not managed by @@ -103,7 +120,7 @@ class WikiExporter { * the most recent version. */ public function allPages() { - return $this->dumpFrom( '' ); + $this->dumpFrom( '' ); } /** @@ -118,7 +135,7 @@ class WikiExporter { if ( $end ) { $condition .= ' AND page_id < ' . intval( $end ); } - return $this->dumpFrom( $condition ); + $this->dumpFrom( $condition ); } /** @@ -133,27 +150,34 @@ class WikiExporter { if ( $end ) { $condition .= ' AND rev_id < ' . intval( $end ); } - return $this->dumpFrom( $condition ); + $this->dumpFrom( $condition ); } /** * @param $title Title */ public function pageByTitle( $title ) { - return $this->dumpFrom( + $this->dumpFrom( 'page_namespace=' . $title->getNamespace() . ' AND page_title=' . $this->db->addQuotes( $title->getDBkey() ) ); } + /** + * @param $name string + * @throws MWException + */ public function pageByName( $name ) { $title = Title::newFromText( $name ); if ( is_null( $title ) ) { throw new MWException( "Can't export invalid title" ); } else { - return $this->pageByTitle( $title ); + $this->pageByTitle( $title ); } } + /** + * @param $names array + */ public function pagesByName( $names ) { foreach ( $names as $name ) { $this->pageByName( $name ); @@ -161,20 +185,28 @@ class WikiExporter { } public function allLogs() { - return $this->dumpFrom( '' ); + $this->dumpFrom( '' ); } + /** + * @param $start int + * @param $end int + */ public function logsByRange( $start, $end ) { $condition = 'log_id >= ' . intval( $start ); if ( $end ) { $condition .= ' AND log_id < ' . intval( $end ); } - return $this->dumpFrom( $condition ); + $this->dumpFrom( $condition ); } - # Generates the distinct list of authors of an article - # Not called by default (depends on $this->list_authors) - # Can be set by Special:Export when not exporting whole history + /** + * Generates the distinct list of authors of an article + * Not called by default (depends on $this->list_authors) + * Can be set by Special:Export when not exporting whole history + * + * @param $cond + */ protected function do_list_authors( $cond ) { wfProfileIn( __METHOD__ ); $this->author_list = ""; @@ -205,13 +237,15 @@ class WikiExporter { wfProfileOut( __METHOD__ ); } + /** + * @param $cond string + * @throws MWException + * @throws Exception + */ protected function dumpFrom( $cond = '' ) { wfProfileIn( __METHOD__ ); # For logging dumps... if ( $this->history & self::LOGS ) { - if ( $this->buffer == WikiExporter::STREAM ) { - $prev = $this->db->bufferResults( false ); - } $where = array( 'user_id = log_user' ); # Hide private logs $hideLogs = LogEventsList::getExcludeClause( $this->db ); @@ -220,16 +254,49 @@ class WikiExporter { if ( $cond ) $where[] = $cond; # Get logging table name for logging.* clause $logging = $this->db->tableName( 'logging' ); - $result = $this->db->select( array( 'logging', 'user' ), - array( "{$logging}.*", 'user_name' ), // grab the user name - $where, - __METHOD__, - array( 'ORDER BY' => 'log_id', 'USE INDEX' => array( 'logging' => 'PRIMARY' ) ) - ); - $wrapper = $this->db->resultObject( $result ); - $this->outputLogStream( $wrapper ); + if ( $this->buffer == WikiExporter::STREAM ) { - $this->db->bufferResults( $prev ); + $prev = $this->db->bufferResults( false ); + } + $wrapper = null; // Assuring $wrapper is not undefined, if exception occurs early + try { + $result = $this->db->select( array( 'logging', 'user' ), + array( "{$logging}.*", 'user_name' ), // grab the user name + $where, + __METHOD__, + array( 'ORDER BY' => 'log_id', 'USE INDEX' => array( 'logging' => 'PRIMARY' ) ) + ); + $wrapper = $this->db->resultObject( $result ); + $this->outputLogStream( $wrapper ); + if ( $this->buffer == WikiExporter::STREAM ) { + $this->db->bufferResults( $prev ); + } + } catch ( Exception $e ) { + // Throwing the exception does not reliably free the resultset, and + // would also leave the connection in unbuffered mode. + + // Freeing result + try { + if ( $wrapper ) { + $wrapper->free(); + } + } catch ( Exception $e2 ) { + // Already in panic mode -> ignoring $e2 as $e has + // higher priority + } + + // Putting database back in previous buffer mode + try { + if ( $this->buffer == WikiExporter::STREAM ) { + $this->db->bufferResults( $prev ); + } + } catch ( Exception $e2 ) { + // Already in panic mode -> ignoring $e2 as $e has + // higher priority + } + + // Inform caller about problem + throw $e; } # For page dumps... } else { @@ -279,7 +346,7 @@ class WikiExporter { } elseif ( $this->history & WikiExporter::RANGE ) { # Dump of revisions within a specified range $join['revision'] = array( 'INNER JOIN', 'page_id=rev_page' ); - $opts['ORDER BY'] = 'rev_page ASC, rev_id ASC'; + $opts['ORDER BY'] = array( 'rev_page ASC', 'rev_id ASC' ); } else { # Uknown history specification parameter? wfProfileOut( __METHOD__ ); @@ -300,20 +367,46 @@ class WikiExporter { $prev = $this->db->bufferResults( false ); } - wfRunHooks( 'ModifyExportQuery', + $wrapper = null; // Assuring $wrapper is not undefined, if exception occurs early + try { + wfRunHooks( '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 ); - if ( $this->list_authors ) { + # Do the query! + $result = $this->db->select( $tables, '*', $cond, __METHOD__, $opts, $join ); + $wrapper = $this->db->resultObject( $result ); + # Output dump results $this->outputPageStream( $wrapper ); - } - if ( $this->buffer == WikiExporter::STREAM ) { - $this->db->bufferResults( $prev ); + if ( $this->buffer == WikiExporter::STREAM ) { + $this->db->bufferResults( $prev ); + } + } catch ( Exception $e ) { + // Throwing the exception does not reliably free the resultset, and + // would also leave the connection in unbuffered mode. + + // Freeing result + try { + if ( $wrapper ) { + $wrapper->free(); + } + } catch ( Exception $e2 ) { + // Already in panic mode -> ignoring $e2 as $e has + // higher priority + } + + // Putting database back in previous buffer mode + try { + if ( $this->buffer == WikiExporter::STREAM ) { + $this->db->bufferResults( $prev ); + } + } catch ( Exception $e2 ) { + // Already in panic mode -> ignoring $e2 as $e has + // higher priority + } + + // Inform caller about problem + throw $e; } } wfProfileOut( __METHOD__ ); @@ -324,7 +417,7 @@ class WikiExporter { * The result set should be sorted/grouped by page to avoid duplicate * page records in the output. * - * The result set will be freed once complete. Should be safe for + * Should be safe for * streaming (non-buffered) queries, as long as it was made on a * separate database connection not managed by LoadBalancer; some * blob storage types will make queries to pull source data. @@ -363,6 +456,9 @@ class WikiExporter { } } + /** + * @param $resultset array + */ protected function outputLogStream( $resultset ) { foreach ( $resultset as $row ) { $output = $this->writer->writeLogItem( $row ); @@ -377,14 +473,16 @@ class WikiExporter { class XmlDumpWriter { /** * Returns the export schema version. + * @deprecated in 1.20; use WikiExporter::schemaVersion() instead * @return string */ function schemaVersion() { - return "0.6"; + wfDeprecated( __METHOD__, '1.20' ); + return WikiExporter::schemaVersion(); } /** - * Opens the XML output stream's root element. + * Opens the XML output stream's root "" element. * This does not include an xml directive, so is safe to include * as a subelement in a larger XML stream. Namespace and XML Schema * references are included. @@ -395,7 +493,7 @@ class XmlDumpWriter { */ function openStream() { global $wgLanguageCode; - $ver = $this->schemaVersion(); + $ver = WikiExporter::schemaVersion(); return Xml::element( 'mediawiki', array( 'xmlns' => "http://www.mediawiki.org/xml/export-$ver/", 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", @@ -408,6 +506,9 @@ class XmlDumpWriter { $this->siteInfo(); } + /** + * @return string + */ function siteInfo() { $info = array( $this->sitename(), @@ -420,20 +521,32 @@ class XmlDumpWriter { "\n \n"; } + /** + * @return string + */ function sitename() { global $wgSitename; return Xml::element( 'sitename', array(), $wgSitename ); } + /** + * @return string + */ function generator() { global $wgVersion; return Xml::element( 'generator', array(), "MediaWiki $wgVersion" ); } + /** + * @return string + */ function homelink() { return Xml::element( 'base', array(), Title::newMainPage()->getCanonicalUrl() ); } + /** + * @return string + */ function caseSetting() { global $wgCapitalLinks; // "case-insensitive" option is reserved for future @@ -441,6 +554,9 @@ class XmlDumpWriter { return Xml::element( 'case', array(), $sensitivity ); } + /** + * @return string + */ function namespaces() { global $wgContLang; $spaces = "\n"; @@ -466,7 +582,7 @@ class XmlDumpWriter { } /** - * Opens a section on the output stream, with data + * Opens a "" section on the output stream, with data * from the given database row. * * @param $row object @@ -486,13 +602,7 @@ class XmlDumpWriter { $out .= ' ' . Xml::element( 'redirect', array( 'title' => self::canonicalTitle( $redirect ) ) ) . "\n"; } } - - if ( $row->rev_sha1 ) { - $out .= " " . Xml::element('sha1', null, strval($row->rev_sha1) ) . "\n"; - } else { - $out .= " \n"; - } - + if ( $row->page_restrictions != '' ) { $out .= ' ' . Xml::element( 'restrictions', array(), strval( $row->page_restrictions ) ) . "\n"; @@ -504,16 +614,17 @@ class XmlDumpWriter { } /** - * Closes a section on the output stream. + * Closes a "" section on the output stream. * * @access private + * @return string */ function closePage() { return " \n"; } /** - * Dumps a section on the output stream, with + * Dumps a "" section on the output stream, with * data filled in from the given database row. * * @param $row object @@ -525,6 +636,9 @@ class XmlDumpWriter { $out = " \n"; $out .= " " . Xml::element( 'id', null, strval( $row->rev_id ) ) . "\n"; + if( $row->rev_parent_id ) { + $out .= " " . Xml::element( 'parentid', null, strval( $row->rev_parent_id ) ) . "\n"; + } $out .= $this->writeTimestamp( $row->rev_timestamp ); @@ -540,7 +654,13 @@ class XmlDumpWriter { if ( $row->rev_deleted & Revision::DELETED_COMMENT ) { $out .= " " . Xml::element( 'comment', array( 'deleted' => 'deleted' ) ) . "\n"; } elseif ( $row->rev_comment != '' ) { - $out .= " " . Xml::elementClean( 'comment', null, strval( $row->rev_comment ) ) . "\n"; + $out .= " " . Xml::elementClean( 'comment', array(), strval( $row->rev_comment ) ) . "\n"; + } + + if ( $row->rev_sha1 && !( $row->rev_deleted & Revision::DELETED_TEXT ) ) { + $out .= " " . Xml::element('sha1', null, strval( $row->rev_sha1 ) ) . "\n"; + } else { + $out .= " \n"; } $text = ''; @@ -568,7 +688,7 @@ class XmlDumpWriter { } /** - * Dumps a section on the output stream, with + * Dumps a "" section on the output stream, with * data filled in from the given database row. * * @param $row object @@ -578,64 +698,78 @@ class XmlDumpWriter { function writeLogItem( $row ) { wfProfileIn( __METHOD__ ); - $out = " \n"; - $out .= " " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n"; + $out = " \n"; + $out .= " " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n"; - $out .= $this->writeTimestamp( $row->log_timestamp ); + $out .= $this->writeTimestamp( $row->log_timestamp, " " ); if ( $row->log_deleted & LogPage::DELETED_USER ) { - $out .= " " . Xml::element( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n"; + $out .= " " . Xml::element( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n"; } else { - $out .= $this->writeContributor( $row->log_user, $row->user_name ); + $out .= $this->writeContributor( $row->log_user, $row->user_name, " " ); } if ( $row->log_deleted & LogPage::DELETED_COMMENT ) { - $out .= " " . Xml::element( 'comment', array( 'deleted' => 'deleted' ) ) . "\n"; + $out .= " " . Xml::element( 'comment', array( 'deleted' => 'deleted' ) ) . "\n"; } elseif ( $row->log_comment != '' ) { - $out .= " " . Xml::elementClean( 'comment', null, strval( $row->log_comment ) ) . "\n"; + $out .= " " . Xml::elementClean( 'comment', null, strval( $row->log_comment ) ) . "\n"; } - $out .= " " . Xml::element( 'type', null, strval( $row->log_type ) ) . "\n"; - $out .= " " . Xml::element( 'action', null, strval( $row->log_action ) ) . "\n"; + $out .= " " . Xml::element( 'type', null, strval( $row->log_type ) ) . "\n"; + $out .= " " . Xml::element( 'action', null, strval( $row->log_action ) ) . "\n"; if ( $row->log_deleted & LogPage::DELETED_ACTION ) { - $out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n"; + $out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n"; } else { $title = Title::makeTitle( $row->log_namespace, $row->log_title ); - $out .= " " . Xml::elementClean( 'logtitle', null, self::canonicalTitle( $title ) ) . "\n"; - $out .= " " . Xml::elementClean( 'params', + $out .= " " . Xml::elementClean( 'logtitle', null, self::canonicalTitle( $title ) ) . "\n"; + $out .= " " . Xml::elementClean( 'params', array( 'xml:space' => 'preserve' ), strval( $row->log_params ) ) . "\n"; } - $out .= " \n"; + $out .= " \n"; wfProfileOut( __METHOD__ ); return $out; } - function writeTimestamp( $timestamp ) { + /** + * @param $timestamp string + * @param $indent string Default to six spaces + * @return string + */ + function writeTimestamp( $timestamp, $indent = " " ) { $ts = wfTimestamp( TS_ISO_8601, $timestamp ); - return " " . Xml::element( 'timestamp', null, $ts ) . "\n"; + return $indent . Xml::element( 'timestamp', null, $ts ) . "\n"; } - function writeContributor( $id, $text ) { - $out = " \n"; + /** + * @param $id + * @param $text string + * @param $indent string Default to six spaces + * @return string + */ + function writeContributor( $id, $text, $indent = " " ) { + $out = $indent . "\n"; if ( $id || !IP::isValid( $text ) ) { - $out .= " " . Xml::elementClean( 'username', null, strval( $text ) ) . "\n"; - $out .= " " . Xml::element( 'id', null, strval( $id ) ) . "\n"; + $out .= $indent . " " . Xml::elementClean( 'username', null, strval( $text ) ) . "\n"; + $out .= $indent . " " . Xml::element( 'id', null, strval( $id ) ) . "\n"; } else { - $out .= " " . Xml::elementClean( 'ip', null, strval( $text ) ) . "\n"; + $out .= $indent . " " . Xml::elementClean( 'ip', null, strval( $text ) ) . "\n"; } - $out .= " \n"; + $out .= $indent . "\n"; return $out; } /** * Warning! This data is potentially inconsistent. :( + * @param $row + * @param $dumpContents bool + * @return string */ function writeUploads( $row, $dumpContents = false ) { - if ( $row->page_namespace == NS_IMAGE ) { + if ( $row->page_namespace == NS_FILE ) { $img = wfLocalFile( $row->page_title ); if ( $img && $img->exists() ) { $out = ''; @@ -670,10 +804,15 @@ class XmlDumpWriter { } else { $contents = ''; } + if ( $file->isDeleted( File::DELETED_COMMENT ) ) { + $comment = Xml::element( 'comment', array( 'deleted' => 'deleted' ) ); + } else { + $comment = Xml::elementClean( 'comment', null, $file->getDescription() ); + } return " \n" . $this->writeTimestamp( $file->getTimestamp() ) . $this->writeContributor( $file->getUser( 'id' ), $file->getUser( 'text' ) ) . - " " . Xml::elementClean( 'comment', null, $file->getDescription() ) . "\n" . + " " . $comment . "\n" . " " . Xml::element( 'filename', null, $file->getName() ) . "\n" . $archiveName . " " . Xml::element( 'src', null, $file->getCanonicalUrl() ) . "\n" . @@ -688,7 +827,7 @@ class XmlDumpWriter { * Return prefixed text form of title, but using the content language's * canonical namespace. This skips any special-casing such as gendered * user namespaces -- which while useful, are not yet listed in the - * XML data so are unsafe in export. + * XML "" data so are unsafe in export. * * @param Title $title * @return string @@ -716,32 +855,55 @@ class XmlDumpWriter { * @ingroup Dump */ class DumpOutput { + + /** + * @param $string string + */ function writeOpenStream( $string ) { $this->write( $string ); } + /** + * @param $string string + */ function writeCloseStream( $string ) { $this->write( $string ); } + /** + * @param $page + * @param $string string + */ function writeOpenPage( $page, $string ) { $this->write( $string ); } + /** + * @param $string string + */ function writeClosePage( $string ) { $this->write( $string ); } + /** + * @param $rev + * @param $string string + */ function writeRevision( $rev, $string ) { $this->write( $string ); } + /** + * @param $rev + * @param $string string + */ function writeLogItem( $rev, $string ) { $this->write( $string ); } /** * Override to write to a different stream type. + * @param $string string * @return bool */ function write( $string ) { @@ -773,6 +935,7 @@ class DumpOutput { /** * Returns the name of the file or files which are * being written to, if there are any. + * @return null */ function getFilenames() { return NULL; @@ -784,27 +947,56 @@ class DumpOutput { * @ingroup Dump */ class DumpFileOutput extends DumpOutput { - protected $handle, $filename; + protected $handle = false, $filename; + /** + * @param $file + */ function __construct( $file ) { $this->handle = fopen( $file, "wt" ); $this->filename = $file; } + /** + * @param $string string + */ + function writeCloseStream( $string ) { + parent::writeCloseStream( $string ); + if ( $this->handle ) { + fclose( $this->handle ); + $this->handle = false; + } + } + + /** + * @param $string string + */ function write( $string ) { fputs( $this->handle, $string ); } + /** + * @param $newname + */ function closeRenameAndReopen( $newname ) { $this->closeAndRename( $newname, true ); } + /** + * @param $newname + * @throws MWException + */ function renameOrException( $newname ) { if (! rename( $this->filename, $newname ) ) { throw new MWException( __METHOD__ . ": rename of file {$this->filename} to $newname failed\n" ); } } + /** + * @param $newname array + * @return mixed + * @throws MWException + */ function checkRenameArgCount( $newname ) { if ( is_array( $newname ) ) { if ( count( $newname ) > 1 ) { @@ -816,10 +1008,17 @@ class DumpFileOutput extends DumpOutput { return $newname; } + /** + * @param $newname mixed + * @param $open bool + */ function closeAndRename( $newname, $open = false ) { $newname = $this->checkRenameArgCount( $newname ); if ( $newname ) { - fclose( $this->handle ); + if ( $this->handle ) { + fclose( $this->handle ); + $this->handle = false; + } $this->renameOrException( $newname ); if ( $open ) { $this->handle = fopen( $this->filename, "wt" ); @@ -827,6 +1026,9 @@ class DumpFileOutput extends DumpOutput { } } + /** + * @return string|null + */ function getFilenames() { return $this->filename; } @@ -840,7 +1042,12 @@ class DumpFileOutput extends DumpOutput { */ class DumpPipeOutput extends DumpFileOutput { protected $command, $filename; + protected $procOpenResource = false; + /** + * @param $command + * @param $file null + */ function __construct( $command, $file = null ) { if ( !is_null( $file ) ) { $command .= " > " . wfEscapeShellArg( $file ); @@ -851,6 +1058,20 @@ class DumpPipeOutput extends DumpFileOutput { $this->filename = $file; } + /** + * @param $string string + */ + function writeCloseStream( $string ) { + parent::writeCloseStream( $string ); + if ( $this->procOpenResource ) { + proc_close( $this->procOpenResource ); + $this->procOpenResource = false; + } + } + + /** + * @param $command + */ function startCommand( $command ) { $spec = array( 0 => array( "pipe", "r" ), @@ -860,15 +1081,28 @@ class DumpPipeOutput extends DumpFileOutput { $this->handle = $pipes[0]; } + /** + * @param mixed $newname + */ function closeRenameAndReopen( $newname ) { $this->closeAndRename( $newname, true ); } + /** + * @param $newname mixed + * @param $open bool + */ function closeAndRename( $newname, $open = false ) { $newname = $this->checkRenameArgCount( $newname ); if ( $newname ) { - fclose( $this->handle ); - proc_close( $this->procOpenResource ); + if ( $this->handle ) { + fclose( $this->handle ); + $this->handle = false; + } + if ( $this->procOpenResource ) { + proc_close( $this->procOpenResource ); + $this->procOpenResource = false; + } $this->renameOrException( $newname ); if ( $open ) { $command = $this->command; @@ -885,6 +1119,10 @@ class DumpPipeOutput extends DumpFileOutput { * @ingroup Dump */ class DumpGZipOutput extends DumpPipeOutput { + + /** + * @param $file string + */ function __construct( $file ) { parent::__construct( "gzip", $file ); } @@ -895,6 +1133,10 @@ class DumpGZipOutput extends DumpPipeOutput { * @ingroup Dump */ class DumpBZip2Output extends DumpPipeOutput { + + /** + * @param $file string + */ function __construct( $file ) { parent::__construct( "bzip2", $file ); } @@ -905,12 +1147,20 @@ class DumpBZip2Output extends DumpPipeOutput { * @ingroup Dump */ class Dump7ZipOutput extends DumpPipeOutput { + + /** + * @param $file string + */ function __construct( $file ) { $command = $this->setup7zCommand( $file ); parent::__construct( $command ); $this->filename = $file; } + /** + * @param $file string + * @return string + */ function setup7zCommand( $file ) { $command = "7za a -bd -si " . wfEscapeShellArg( $file ); // Suppress annoying useless crap from p7zip @@ -919,6 +1169,10 @@ class Dump7ZipOutput extends DumpPipeOutput { return( $command ); } + /** + * @param $newname string + * @param $open bool + */ function closeAndRename( $newname, $open = false ) { $newname = $this->checkRenameArgCount( $newname ); if ( $newname ) { @@ -933,8 +1187,6 @@ class Dump7ZipOutput extends DumpPipeOutput { } } - - /** * Dump output filter class. * This just does output filtering and streaming; XML formatting is done @@ -942,18 +1194,44 @@ class Dump7ZipOutput extends DumpPipeOutput { * @ingroup Dump */ class DumpFilter { + + /** + * @var DumpOutput + * FIXME will need to be made protected whenever legacy code + * is updated. + */ + public $sink; + + /** + * @var bool + */ + protected $sendingThisPage; + + /** + * @param $sink DumpOutput + */ function __construct( &$sink ) { $this->sink =& $sink; } + /** + * @param $string string + */ function writeOpenStream( $string ) { $this->sink->writeOpenStream( $string ); } + /** + * @param $string string + */ function writeCloseStream( $string ) { $this->sink->writeCloseStream( $string ); } + /** + * @param $page + * @param $string string + */ function writeOpenPage( $page, $string ) { $this->sendingThisPage = $this->pass( $page, $string ); if ( $this->sendingThisPage ) { @@ -961,6 +1239,9 @@ class DumpFilter { } } + /** + * @param $string string + */ function writeClosePage( $string ) { if ( $this->sendingThisPage ) { $this->sink->writeClosePage( $string ); @@ -968,30 +1249,49 @@ class DumpFilter { } } + /** + * @param $rev + * @param $string string + */ function writeRevision( $rev, $string ) { if ( $this->sendingThisPage ) { $this->sink->writeRevision( $rev, $string ); } } + /** + * @param $rev + * @param $string string + */ function writeLogItem( $rev, $string ) { $this->sink->writeRevision( $rev, $string ); } + /** + * @param $newname string + */ function closeRenameAndReopen( $newname ) { $this->sink->closeRenameAndReopen( $newname ); } + /** + * @param $newname string + * @param $open bool + */ function closeAndRename( $newname, $open = false ) { $this->sink->closeAndRename( $newname, $open ); } + /** + * @return array + */ function getFilenames() { return $this->sink->getFilenames(); } /** * Override for page-based filter types. + * @param $page * @return bool */ function pass( $page ) { @@ -1004,6 +1304,11 @@ class DumpFilter { * @ingroup Dump */ class DumpNotalkFilter extends DumpFilter { + + /** + * @param $page + * @return bool + */ function pass( $page ) { return !MWNamespace::isTalk( $page->page_namespace ); } @@ -1017,6 +1322,10 @@ class DumpNamespaceFilter extends DumpFilter { var $invert = false; var $namespaces = array(); + /** + * @param $sink DumpOutput + * @param $param + */ function __construct( &$sink, $param ) { parent::__construct( $sink ); @@ -1059,6 +1368,10 @@ class DumpNamespaceFilter extends DumpFilter { } } + /** + * @param $page + * @return bool + */ function pass( $page ) { $match = isset( $this->namespaces[$page->page_namespace] ); return $this->invert xor $match; @@ -1073,11 +1386,18 @@ class DumpNamespaceFilter extends DumpFilter { class DumpLatestFilter extends DumpFilter { var $page, $pageString, $rev, $revString; + /** + * @param $page + * @param $string string + */ function writeOpenPage( $page, $string ) { $this->page = $page; $this->pageString = $string; } + /** + * @param $string string + */ function writeClosePage( $string ) { if ( $this->rev ) { $this->sink->writeOpenPage( $this->page, $this->pageString ); @@ -1090,6 +1410,10 @@ class DumpLatestFilter extends DumpFilter { $this->pageString = null; } + /** + * @param $rev + * @param $string string + */ function writeRevision( $rev, $string ) { if ( $rev->rev_id == $this->page->page_latest ) { $this->rev = $rev; @@ -1103,51 +1427,82 @@ class DumpLatestFilter extends DumpFilter { * @ingroup Dump */ class DumpMultiWriter { + + /** + * @param $sinks + */ function __construct( $sinks ) { $this->sinks = $sinks; $this->count = count( $sinks ); } + /** + * @param $string string + */ function writeOpenStream( $string ) { for ( $i = 0; $i < $this->count; $i++ ) { $this->sinks[$i]->writeOpenStream( $string ); } } + /** + * @param $string string + */ function writeCloseStream( $string ) { for ( $i = 0; $i < $this->count; $i++ ) { $this->sinks[$i]->writeCloseStream( $string ); } } + /** + * @param $page + * @param $string string + */ function writeOpenPage( $page, $string ) { for ( $i = 0; $i < $this->count; $i++ ) { $this->sinks[$i]->writeOpenPage( $page, $string ); } } + /** + * @param $string + */ function writeClosePage( $string ) { for ( $i = 0; $i < $this->count; $i++ ) { $this->sinks[$i]->writeClosePage( $string ); } } + /** + * @param $rev + * @param $string + */ function writeRevision( $rev, $string ) { for ( $i = 0; $i < $this->count; $i++ ) { $this->sinks[$i]->writeRevision( $rev, $string ); } } + /** + * @param $newnames + */ function closeRenameAndReopen( $newnames ) { $this->closeAndRename( $newnames, true ); } + /** + * @param $newnames array + * @param bool $open + */ function closeAndRename( $newnames, $open = false ) { for ( $i = 0; $i < $this->count; $i++ ) { $this->sinks[$i]->closeAndRename( $newnames[$i], $open ); } } + /** + * @return array + */ function getFilenames() { $filenames = array(); for ( $i = 0; $i < $this->count; $i++ ) { @@ -1158,6 +1513,10 @@ class DumpMultiWriter { } +/** + * @param $string string + * @return string + */ function xmlsafe( $string ) { wfProfileIn( __FUNCTION__ ); -- cgit v1.2.2