const TEXT = 0;
const STUB = 1;
+ var $buffer;
+
+ var $text;
+
+ /**
+ * @var DumpOutput
+ */
+ var $sink;
+
/**
* If using WikiExporter::STREAM to stream a large amount of data,
* provide a database connection which is not managed by
' 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 ) ) {
}
}
+ /**
+ * @param $names array
+ */
public function pagesByName( $names ) {
foreach ( $names as $name ) {
$this->pageByName( $name );
$this->dumpFrom( '' );
}
+ /**
+ * @param $start int
+ * @param $end int
+ */
public function logsByRange( $start, $end ) {
$condition = 'log_id >= ' . intval( $start );
if ( $end ) {
$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 = "<contributors>";
wfProfileOut( __METHOD__ );
}
+ /**
+ * @param $cond string
+ * @throws MWException
+ * @throws Exception
+ */
protected function dumpFrom( $cond = '' ) {
wfProfileIn( __METHOD__ );
# For logging dumps...
}
}
+ /**
+ * @param $resultset array
+ */
protected function outputLogStream( $resultset ) {
foreach ( $resultset as $row ) {
$output = $this->writer->writeLogItem( $row );
$this->siteInfo();
}
+ /**
+ * @return string
+ */
function siteInfo() {
$info = array(
$this->sitename(),
"\n </siteinfo>\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
return Xml::element( 'case', array(), $sensitivity );
}
+ /**
+ * @return string
+ */
function namespaces() {
global $wgContLang;
$spaces = "<namespaces>\n";
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";
}
$text = '';
return $out;
}
+ /**
+ * @param $timestamp string
+ * @return string
+ */
function writeTimestamp( $timestamp ) {
$ts = wfTimestamp( TS_ISO_8601, $timestamp );
return " " . Xml::element( 'timestamp', null, $ts ) . "\n";
}
+ /**
+ * @param $id
+ * @param $text string
+ * @return string
+ */
function writeContributor( $id, $text ) {
$out = " <contributor>\n";
if ( $id || !IP::isValid( $text ) ) {
/**
* Warning! This data is potentially inconsistent. :(
+ * @param $row
+ * @param $dumpContents bool
* @return string
*/
function writeUploads( $row, $dumpContents = false ) {
* @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 ) {
class DumpFileOutput extends DumpOutput {
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 ) {
}
}
+ /**
+ * @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 ) {
return $newname;
}
+ /**
+ * @param $newname mixed
+ * @param $open bool
+ */
function closeAndRename( $newname, $open = false ) {
$newname = $this->checkRenameArgCount( $newname );
if ( $newname ) {
}
}
+ /**
+ * @return string|null
+ */
function getFilenames() {
return $this->filename;
}
protected $command, $filename;
protected $procOpenResource = false;
+ /**
+ * @param $command
+ * @param $file null
+ */
function __construct( $command, $file = null ) {
if ( !is_null( $file ) ) {
$command .= " > " . wfEscapeShellArg( $file );
$this->filename = $file;
}
+ /**
+ * @param $string string
+ */
function writeCloseStream( $string ) {
parent::writeCloseStream( $string );
if ( $this->procOpenResource ) {
}
}
+ /**
+ * @param $command
+ */
function startCommand( $command ) {
$spec = array(
0 => array( "pipe", "r" ),
$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 ) {
* @ingroup Dump
*/
class DumpGZipOutput extends DumpPipeOutput {
+
+ /**
+ * @param $file string
+ */
function __construct( $file ) {
parent::__construct( "gzip", $file );
}
* @ingroup Dump
*/
class DumpBZip2Output extends DumpPipeOutput {
+
+ /**
+ * @param $file string
+ */
function __construct( $file ) {
parent::__construct( "bzip2", $file );
}
* @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
return( $command );
}
+ /**
+ * @param $newname string
+ * @param $open bool
+ */
function closeAndRename( $newname, $open = false ) {
$newname = $this->checkRenameArgCount( $newname );
if ( $newname ) {
}
}
-
-
/**
* Dump output filter class.
* This just does output filtering and streaming; XML formatting is done
* @ingroup Dump
*/
class DumpFilter {
+
+ /**
+ * @var DumpOutput
+ */
+ protected $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 ) {
}
}
+ /**
+ * @param $string string
+ */
function writeClosePage( $string ) {
if ( $this->sendingThisPage ) {
$this->sink->writeClosePage( $string );
}
}
+ /**
+ * @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 ) {
* @ingroup Dump
*/
class DumpNotalkFilter extends DumpFilter {
+
+ /**
+ * @param $page
+ * @return bool
+ */
function pass( $page ) {
return !MWNamespace::isTalk( $page->page_namespace );
}
var $invert = false;
var $namespaces = array();
+ /**
+ * @param $sink DumpOutput
+ * @param $param
+ */
function __construct( &$sink, $param ) {
parent::__construct( $sink );
}
}
+ /**
+ * @param $page
+ * @return bool
+ */
function pass( $page ) {
$match = isset( $this->namespaces[$page->page_namespace] );
return $this->invert xor $match;
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 );
$this->pageString = null;
}
+ /**
+ * @param $rev
+ * @param $string string
+ */
function writeRevision( $rev, $string ) {
if ( $rev->rev_id == $this->page->page_latest ) {
$this->rev = $rev;
* @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++ ) {
}
+/**
+ * @param $string string
+ * @return string
+ */
function xmlsafe( $string ) {
wfProfileIn( __FUNCTION__ );