2005-10-02 04:05:40 +00:00
|
|
|
<?php
|
2006-03-16 19:04:25 +00:00
|
|
|
# Copyright (C) 2003, 2005, 2006 Brion Vibber <brion@pobox.com>
|
2005-10-02 04:05:40 +00:00
|
|
|
# http://www.mediawiki.org/
|
2006-01-07 13:09:30 +00:00
|
|
|
#
|
2005-10-02 04:05:40 +00:00
|
|
|
# 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
|
2006-01-07 13:09:30 +00:00
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
2005-10-02 04:05:40 +00:00
|
|
|
# (at your option) any later version.
|
2006-01-07 13:09:30 +00:00
|
|
|
#
|
2005-10-02 04:05:40 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
2006-01-07 13:09:30 +00:00
|
|
|
#
|
2005-10-02 04:05:40 +00:00
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
2006-04-05 07:43:17 +00:00
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-10-02 04:05:40 +00:00
|
|
|
# http://www.gnu.org/copyleft/gpl.html
|
2006-10-03 13:00:52 +00:00
|
|
|
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
/**
|
|
|
|
|
* @defgroup Dump Dump
|
|
|
|
|
*/
|
Some small doc tweaks to reduce Doxygen warnings, namely:
* @link. You might think @link would surely mean "here comes a web URL" ... but @link is a valid command
in Doxygen, which means an entirely different kind of link (an internal link to somewhere, so that you can separate
documentation and implementation). The result is a mess, and the best solution I can see is to use "@see" instead of "@link".
* Warning: argument `nourl' of command @param is not found in the argument list of Linker::makeMediaLinkObj($title,$text='')
* Moving few class descriptions to right above classes, and/or formatting into Javadoc style.
* "@addtogroup Special Pages" --> "@addtogroup SpecialPage" so that all special pages have the same @addtogroup tag.
* @fixme --> @todo (must have missed these before)
* "@param $specialPage @see" remove the "@" in the "@see" to stop warning.
* @throws wants type, then a brief description, to stop warning.
This last one is for PHPdocumentor only, but it fixes something for PHPDocumentor, and should be neutral for Doxygen:
* WARNING in includes/api/ApiFormatYaml_spyc.php on line 860: docblock template never terminated with /**#@-*/
2007-04-18 09:50:10 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage Dump
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
|
|
|
|
class WikiExporter {
|
2006-03-23 08:50:31 +00:00
|
|
|
var $list_authors = false ; # Return distinct author list (when not returning full history)
|
|
|
|
|
var $author_list = "" ;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-04 02:03:52 +00:00
|
|
|
var $dumpUploads = false;
|
2007-01-17 22:32:40 +00:00
|
|
|
|
2009-03-02 19:48:41 +00:00
|
|
|
const FULL = 1;
|
|
|
|
|
const CURRENT = 2;
|
|
|
|
|
const STABLE = 4; // extension defined
|
|
|
|
|
const LOGS = 8;
|
2006-10-03 13:00:52 +00:00
|
|
|
|
|
|
|
|
const BUFFER = 0;
|
|
|
|
|
const STREAM = 1;
|
|
|
|
|
|
|
|
|
|
const TEXT = 0;
|
|
|
|
|
const STUB = 1;
|
|
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
2006-10-03 13:00:52 +00:00
|
|
|
* If using WikiExporter::STREAM to stream a large amount of data,
|
2005-10-02 04:05:40 +00:00
|
|
|
* provide a database connection which is not managed by
|
|
|
|
|
* LoadBalancer to read from: some history blob types will
|
|
|
|
|
* make additional queries to pull source data while the
|
|
|
|
|
* main query is still running.
|
|
|
|
|
*
|
2008-05-22 19:48:26 +00:00
|
|
|
* @param $db Database
|
|
|
|
|
* @param $history Mixed: one of WikiExporter::FULL or WikiExporter::CURRENT,
|
|
|
|
|
* or an associative array:
|
|
|
|
|
* offset: non-inclusive offset at which to start the query
|
|
|
|
|
* limit: maximum number of rows to return
|
|
|
|
|
* dir: "asc" or "desc" timestamp order
|
|
|
|
|
* @param $buffer Int: one of WikiExporter::BUFFER or WikiExporter::STREAM
|
2009-10-04 21:21:30 +00:00
|
|
|
* @param $text Int: one of WikiExporter::TEXT or WikiExporter::STUB
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
2007-01-20 13:34:31 +00:00
|
|
|
function __construct( &$db, $history = WikiExporter::CURRENT,
|
2006-10-03 13:00:52 +00:00
|
|
|
$buffer = WikiExporter::BUFFER, $text = WikiExporter::TEXT ) {
|
2005-10-02 04:05:40 +00:00
|
|
|
$this->db =& $db;
|
|
|
|
|
$this->history = $history;
|
|
|
|
|
$this->buffer = $buffer;
|
|
|
|
|
$this->writer = new XmlDumpWriter();
|
|
|
|
|
$this->sink = new DumpOutput();
|
2005-10-16 17:33:41 +00:00
|
|
|
$this->text = $text;
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
|
|
|
|
* Set the DumpOutput or DumpFilter object which will receive
|
|
|
|
|
* various row objects and XML output for filtering. Filters
|
|
|
|
|
* can be chained or used as callbacks.
|
|
|
|
|
*
|
2008-05-22 19:48:26 +00:00
|
|
|
* @param $sink mixed
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
2008-09-18 16:41:43 +00:00
|
|
|
public function setOutputSink( &$sink ) {
|
2005-10-02 04:05:40 +00:00
|
|
|
$this->sink =& $sink;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2008-09-18 16:41:43 +00:00
|
|
|
public function openStream() {
|
2005-10-02 04:05:40 +00:00
|
|
|
$output = $this->writer->openStream();
|
|
|
|
|
$this->sink->writeOpenStream( $output );
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-18 16:41:43 +00:00
|
|
|
public function closeStream() {
|
2005-10-02 04:05:40 +00:00
|
|
|
$output = $this->writer->closeStream();
|
|
|
|
|
$this->sink->writeCloseStream( $output );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dumps a series of page and revision records for all pages
|
|
|
|
|
* in the database, either including complete history or only
|
|
|
|
|
* the most recent version.
|
|
|
|
|
*/
|
2008-09-18 16:41:43 +00:00
|
|
|
public function allPages() {
|
2005-10-02 04:05:40 +00:00
|
|
|
return $this->dumpFrom( '' );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
|
|
|
|
* Dumps a series of page and revision records for those pages
|
|
|
|
|
* in the database falling within the page_id range given.
|
2008-05-22 19:48:26 +00:00
|
|
|
* @param $start Int: inclusive lower limit (this id is included)
|
|
|
|
|
* @param $end Int: Exclusive upper limit (this id is not included)
|
2005-10-02 04:05:40 +00:00
|
|
|
* If 0, no upper limit.
|
|
|
|
|
*/
|
2008-09-18 16:41:43 +00:00
|
|
|
public function pagesByRange( $start, $end ) {
|
2005-10-02 04:05:40 +00:00
|
|
|
$condition = 'page_id >= ' . intval( $start );
|
|
|
|
|
if( $end ) {
|
|
|
|
|
$condition .= ' AND page_id < ' . intval( $end );
|
|
|
|
|
}
|
|
|
|
|
return $this->dumpFrom( $condition );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
2008-05-22 19:48:26 +00:00
|
|
|
* @param $title Title
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
2008-09-18 16:41:43 +00:00
|
|
|
public function pageByTitle( $title ) {
|
2005-10-02 04:05:40 +00:00
|
|
|
return $this->dumpFrom(
|
|
|
|
|
'page_namespace=' . $title->getNamespace() .
|
2008-01-14 09:26:36 +00:00
|
|
|
' AND page_title=' . $this->db->addQuotes( $title->getDBkey() ) );
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2008-09-18 16:41:43 +00:00
|
|
|
public function pageByName( $name ) {
|
2005-10-02 04:05:40 +00:00
|
|
|
$title = Title::newFromText( $name );
|
|
|
|
|
if( is_null( $title ) ) {
|
|
|
|
|
return new WikiError( "Can't export invalid title" );
|
|
|
|
|
} else {
|
|
|
|
|
return $this->pageByTitle( $title );
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2008-09-18 16:41:43 +00:00
|
|
|
public function pagesByName( $names ) {
|
2005-10-02 04:05:40 +00:00
|
|
|
foreach( $names as $name ) {
|
|
|
|
|
$this->pageByName( $name );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-18 16:41:43 +00:00
|
|
|
public function allLogs() {
|
|
|
|
|
return $this->dumpFrom( '' );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2008-09-18 16:41:43 +00:00
|
|
|
public function logsByRange( $start, $end ) {
|
|
|
|
|
$condition = 'log_id >= ' . intval( $start );
|
|
|
|
|
if( $end ) {
|
|
|
|
|
$condition .= ' AND log_id < ' . intval( $end );
|
|
|
|
|
}
|
|
|
|
|
return $this->dumpFrom( $condition );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-03-23 08:50:31 +00:00
|
|
|
# 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
|
2008-09-18 16:41:43 +00:00
|
|
|
protected function do_list_authors( $page , $revision , $cond ) {
|
2006-03-23 08:50:31 +00:00
|
|
|
$fname = "do_list_authors" ;
|
|
|
|
|
wfProfileIn( $fname );
|
|
|
|
|
$this->author_list = "<contributors>";
|
2007-03-28 07:28:21 +00:00
|
|
|
//rev_deleted
|
2009-06-13 06:31:38 +00:00
|
|
|
$nothidden = '('.$this->db->bitAnd('rev_deleted', Revision::DELETED_USER) . ') = 0';
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-09-18 16:41:43 +00:00
|
|
|
$sql = "SELECT DISTINCT rev_user_text,rev_user FROM {$page},{$revision}
|
|
|
|
|
WHERE page_id=rev_page AND $nothidden AND " . $cond ;
|
2006-03-23 08:50:31 +00:00
|
|
|
$result = $this->db->query( $sql, $fname );
|
|
|
|
|
$resultset = $this->db->resultObject( $result );
|
|
|
|
|
while( $row = $resultset->fetchObject() ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->author_list .= "<contributor>" .
|
|
|
|
|
"<username>" .
|
|
|
|
|
htmlentities( $row->rev_user_text ) .
|
|
|
|
|
"</username>" .
|
|
|
|
|
"<id>" .
|
2006-03-23 08:50:31 +00:00
|
|
|
$row->rev_user .
|
2008-04-14 07:45:50 +00:00
|
|
|
"</id>" .
|
2006-03-23 08:50:31 +00:00
|
|
|
"</contributor>";
|
|
|
|
|
}
|
|
|
|
|
wfProfileOut( $fname );
|
|
|
|
|
$this->author_list .= "</contributors>";
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-18 16:41:43 +00:00
|
|
|
protected function dumpFrom( $cond = '' ) {
|
2009-03-02 19:48:41 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
|
|
|
|
# For logging dumps...
|
2008-09-18 00:02:57 +00:00
|
|
|
if( $this->history & self::LOGS ) {
|
2009-03-01 20:04:52 +00:00
|
|
|
if( $this->buffer == WikiExporter::STREAM ) {
|
|
|
|
|
$prev = $this->db->bufferResults( false );
|
|
|
|
|
}
|
2008-09-18 00:02:57 +00:00
|
|
|
$where = array( 'user_id = log_user' );
|
|
|
|
|
# Hide private logs
|
2009-03-01 20:04:52 +00:00
|
|
|
$hideLogs = LogEventsList::getExcludeClause( $this->db );
|
|
|
|
|
if( $hideLogs ) $where[] = $hideLogs;
|
|
|
|
|
# Add on any caller specified conditions
|
2008-09-18 00:02:57 +00:00
|
|
|
if( $cond ) $where[] = $cond;
|
2009-02-28 19:10:37 +00:00
|
|
|
# Get logging table name for logging.* clause
|
|
|
|
|
$logging = $this->db->tableName('logging');
|
2008-09-18 00:02:57 +00:00
|
|
|
$result = $this->db->select( array('logging','user'),
|
2009-02-28 19:10:37 +00:00
|
|
|
array( "{$logging}.*", 'user_name' ), // grab the user name
|
2008-09-18 00:02:57 +00:00
|
|
|
$where,
|
2009-03-01 20:04:52 +00:00
|
|
|
__METHOD__,
|
2008-09-18 16:41:43 +00:00
|
|
|
array( 'ORDER BY' => 'log_id', 'USE INDEX' => array('logging' => 'PRIMARY') )
|
2008-09-18 00:02:57 +00:00
|
|
|
);
|
|
|
|
|
$wrapper = $this->db->resultObject( $result );
|
2009-04-14 14:42:50 +00:00
|
|
|
$this->outputLogStream( $wrapper );
|
2009-03-01 20:04:52 +00:00
|
|
|
if( $this->buffer == WikiExporter::STREAM ) {
|
|
|
|
|
$this->db->bufferResults( $prev );
|
|
|
|
|
}
|
2008-09-18 00:02:57 +00:00
|
|
|
# For page dumps...
|
2008-09-18 16:41:43 +00:00
|
|
|
} else {
|
2009-03-02 19:48:41 +00:00
|
|
|
$tables = array( 'page', 'revision' );
|
|
|
|
|
$opts = array( 'ORDER BY' => 'page_id ASC' );
|
|
|
|
|
$opts['USE INDEX'] = array();
|
|
|
|
|
$join = array();
|
2009-09-29 21:37:07 +00:00
|
|
|
if( is_array( $this->history ) ) {
|
|
|
|
|
# Time offset/limit for all pages/history...
|
2009-03-02 19:48:41 +00:00
|
|
|
$revJoin = 'page_id=rev_page';
|
|
|
|
|
# Set time order
|
|
|
|
|
if( $this->history['dir'] == 'asc' ) {
|
2008-09-18 16:41:43 +00:00
|
|
|
$op = '>';
|
2009-03-02 19:48:41 +00:00
|
|
|
$opts['ORDER BY'] = 'rev_timestamp ASC';
|
2008-09-18 16:41:43 +00:00
|
|
|
} else {
|
|
|
|
|
$op = '<';
|
2009-03-02 19:48:41 +00:00
|
|
|
$opts['ORDER BY'] = 'rev_timestamp DESC';
|
2008-09-18 16:41:43 +00:00
|
|
|
}
|
2009-03-02 19:48:41 +00:00
|
|
|
# Set offset
|
|
|
|
|
if( !empty( $this->history['offset'] ) ) {
|
|
|
|
|
$revJoin .= " AND rev_timestamp $op " .
|
|
|
|
|
$this->db->addQuotes( $this->db->timestamp( $this->history['offset'] ) );
|
2008-09-18 16:41:43 +00:00
|
|
|
}
|
2009-03-02 19:48:41 +00:00
|
|
|
$join['revision'] = array('INNER JOIN',$revJoin);
|
|
|
|
|
# Set query limit
|
|
|
|
|
if( !empty( $this->history['limit'] ) ) {
|
|
|
|
|
$opts['LIMIT'] = intval( $this->history['limit'] );
|
2008-09-18 16:41:43 +00:00
|
|
|
}
|
2009-09-14 12:57:37 +00:00
|
|
|
} elseif( $this->history & WikiExporter::FULL ) {
|
2009-09-29 21:37:07 +00:00
|
|
|
# Full history dumps...
|
2009-09-14 12:57:37 +00:00
|
|
|
$join['revision'] = array('INNER JOIN','page_id=rev_page');
|
2009-09-29 21:37:07 +00:00
|
|
|
} elseif( $this->history & WikiExporter::CURRENT ) {
|
|
|
|
|
# Latest revision dumps...
|
|
|
|
|
if( $this->list_authors && $cond != '' ) { // List authors, if so desired
|
|
|
|
|
list($page,$revision) = $this->db->tableNamesN('page','revision');
|
|
|
|
|
$this->do_list_authors( $page, $revision, $cond );
|
|
|
|
|
}
|
|
|
|
|
$join['revision'] = array('INNER JOIN','page_id=rev_page AND page_latest=rev_id');
|
|
|
|
|
} elseif( $this->history & WikiExporter::STABLE ) {
|
|
|
|
|
# "Stable" revision dumps...
|
|
|
|
|
# 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__ );
|
|
|
|
|
return new WikiError( __METHOD__." given invalid history dump type." );
|
|
|
|
|
}
|
2006-08-05 14:10:10 +00:00
|
|
|
} else {
|
2009-09-29 21:37:07 +00:00
|
|
|
# Uknown history specification parameter?
|
2009-03-02 19:48:41 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return new WikiError( __METHOD__." given invalid history dump type." );
|
|
|
|
|
}
|
|
|
|
|
# Query optimization hacks
|
|
|
|
|
if( $cond == '' ) {
|
|
|
|
|
$opts[] = 'STRAIGHT_JOIN';
|
|
|
|
|
$opts['USE INDEX']['page'] = 'PRIMARY';
|
|
|
|
|
}
|
|
|
|
|
# Build text join options
|
|
|
|
|
if( $this->text != WikiExporter::STUB ) { // 1-pass
|
|
|
|
|
$tables[] = 'text';
|
|
|
|
|
$join['text'] = array('INNER JOIN','rev_text_id=old_id');
|
2006-08-05 14:10:10 +00:00
|
|
|
}
|
2008-09-18 16:41:43 +00:00
|
|
|
|
|
|
|
|
if( $this->buffer == WikiExporter::STREAM ) {
|
|
|
|
|
$prev = $this->db->bufferResults( false );
|
2006-08-05 14:10:10 +00:00
|
|
|
}
|
2009-07-27 17:57:51 +00:00
|
|
|
|
|
|
|
|
wfRunHooks( 'ModifyExportQuery',
|
|
|
|
|
array( $this->db, &$tables, &$cond, &$opts, &$join ) );
|
2009-03-02 19:48:41 +00:00
|
|
|
|
|
|
|
|
# Do the query!
|
|
|
|
|
$result = $this->db->select( $tables, '*', $cond, __METHOD__, $opts, $join );
|
2008-09-18 16:41:43 +00:00
|
|
|
$wrapper = $this->db->resultObject( $result );
|
2009-03-02 19:48:41 +00:00
|
|
|
# Output dump results
|
2008-09-18 00:02:57 +00:00
|
|
|
$this->outputPageStream( $wrapper );
|
2009-03-02 19:48:41 +00:00
|
|
|
if( $this->list_authors ) {
|
2008-09-18 16:41:43 +00:00
|
|
|
$this->outputPageStream( $wrapper );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2008-09-18 16:41:43 +00:00
|
|
|
if( $this->buffer == WikiExporter::STREAM ) {
|
|
|
|
|
$this->db->bufferResults( $prev );
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-03-02 19:48:41 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
|
|
|
|
* Runs through a query result set dumping page and revision records.
|
|
|
|
|
* 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
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2008-05-22 19:48:26 +00:00
|
|
|
* @param $resultset ResultWrapper
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
2008-09-18 16:41:43 +00:00
|
|
|
protected function outputPageStream( $resultset ) {
|
2005-10-02 04:05:40 +00:00
|
|
|
$last = null;
|
|
|
|
|
while( $row = $resultset->fetchObject() ) {
|
|
|
|
|
if( is_null( $last ) ||
|
|
|
|
|
$last->page_namespace != $row->page_namespace ||
|
|
|
|
|
$last->page_title != $row->page_title ) {
|
|
|
|
|
if( isset( $last ) ) {
|
2008-03-04 02:03:52 +00:00
|
|
|
$output = '';
|
|
|
|
|
if( $this->dumpUploads ) {
|
|
|
|
|
$output .= $this->writer->writeUploads( $last );
|
|
|
|
|
}
|
|
|
|
|
$output .= $this->writer->closePage();
|
2005-10-02 04:05:40 +00:00
|
|
|
$this->sink->writeClosePage( $output );
|
|
|
|
|
}
|
|
|
|
|
$output = $this->writer->openPage( $row );
|
|
|
|
|
$this->sink->writeOpenPage( $row, $output );
|
|
|
|
|
$last = $row;
|
|
|
|
|
}
|
|
|
|
|
$output = $this->writer->writeRevision( $row );
|
|
|
|
|
$this->sink->writeRevision( $row, $output );
|
|
|
|
|
}
|
|
|
|
|
if( isset( $last ) ) {
|
2008-03-04 02:03:52 +00:00
|
|
|
$output = '';
|
|
|
|
|
if( $this->dumpUploads ) {
|
|
|
|
|
$output .= $this->writer->writeUploads( $last );
|
|
|
|
|
}
|
|
|
|
|
$output .= $this->author_list;
|
|
|
|
|
$output .= $this->writer->closePage();
|
2005-10-02 04:05:40 +00:00
|
|
|
$this->sink->writeClosePage( $output );
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-09-18 00:02:57 +00:00
|
|
|
|
2008-09-18 16:41:43 +00:00
|
|
|
protected function outputLogStream( $resultset ) {
|
2008-09-18 00:02:57 +00:00
|
|
|
while( $row = $resultset->fetchObject() ) {
|
|
|
|
|
$output = $this->writer->writeLogItem( $row );
|
|
|
|
|
$this->sink->writeLogItem( $row, $output );
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
|
|
|
|
|
2007-04-20 08:55:14 +00:00
|
|
|
/**
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Dump
|
2007-04-20 08:55:14 +00:00
|
|
|
*/
|
2005-10-02 04:05:40 +00:00
|
|
|
class XmlDumpWriter {
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
|
|
|
|
* Returns the export schema version.
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
function schemaVersion() {
|
2009-09-18 17:34:56 +00:00
|
|
|
return "0.4";
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
|
|
|
|
* Opens the XML output stream's root <mediawiki> 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.
|
|
|
|
|
*
|
|
|
|
|
* Output will be encoded in UTF-8.
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
function openStream() {
|
|
|
|
|
global $wgContLanguageCode;
|
|
|
|
|
$ver = $this->schemaVersion();
|
2008-12-14 19:14:21 +00:00
|
|
|
return Xml::element( 'mediawiki', array(
|
2005-10-02 04:05:40 +00:00
|
|
|
'xmlns' => "http://www.mediawiki.org/xml/export-$ver/",
|
|
|
|
|
'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
|
|
|
|
|
'xsi:schemaLocation' => "http://www.mediawiki.org/xml/export-$ver/ " .
|
|
|
|
|
"http://www.mediawiki.org/xml/export-$ver.xsd",
|
|
|
|
|
'version' => $ver,
|
|
|
|
|
'xml:lang' => $wgContLanguageCode ),
|
|
|
|
|
null ) .
|
|
|
|
|
"\n" .
|
|
|
|
|
$this->siteInfo();
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function siteInfo() {
|
|
|
|
|
$info = array(
|
|
|
|
|
$this->sitename(),
|
|
|
|
|
$this->homelink(),
|
|
|
|
|
$this->generator(),
|
|
|
|
|
$this->caseSetting(),
|
|
|
|
|
$this->namespaces() );
|
|
|
|
|
return " <siteinfo>\n " .
|
|
|
|
|
implode( "\n ", $info ) .
|
|
|
|
|
"\n </siteinfo>\n";
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function sitename() {
|
|
|
|
|
global $wgSitename;
|
2008-12-14 19:14:21 +00:00
|
|
|
return Xml::element( 'sitename', array(), $wgSitename );
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function generator() {
|
|
|
|
|
global $wgVersion;
|
2008-12-14 19:14:21 +00:00
|
|
|
return Xml::element( 'generator', array(), "MediaWiki $wgVersion" );
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function homelink() {
|
2008-12-14 19:14:21 +00:00
|
|
|
return Xml::element( 'base', array(), Title::newMainPage()->getFullUrl() );
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function caseSetting() {
|
|
|
|
|
global $wgCapitalLinks;
|
|
|
|
|
// "case-insensitive" option is reserved for future
|
|
|
|
|
$sensitivity = $wgCapitalLinks ? 'first-letter' : 'case-sensitive';
|
2008-12-14 19:14:21 +00:00
|
|
|
return Xml::element( 'case', array(), $sensitivity );
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function namespaces() {
|
|
|
|
|
global $wgContLang;
|
2009-01-18 05:54:27 +00:00
|
|
|
$spaces = "<namespaces>\n";
|
2005-10-02 04:05:40 +00:00
|
|
|
foreach( $wgContLang->getFormattedNamespaces() as $ns => $title ) {
|
2009-10-09 12:52:16 +00:00
|
|
|
$spaces .= ' ' .
|
|
|
|
|
Xml::element( 'namespace',
|
|
|
|
|
array( 'key' => $ns,
|
|
|
|
|
'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
|
|
|
|
|
), $title ) . "\n";
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
|
|
|
|
$spaces .= " </namespaces>";
|
|
|
|
|
return $spaces;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
|
|
|
|
* Closes the output stream with the closing root element.
|
|
|
|
|
* Call when finished dumping things.
|
|
|
|
|
*/
|
|
|
|
|
function closeStream() {
|
|
|
|
|
return "</mediawiki>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
|
|
|
|
* Opens a <page> section on the output stream, with data
|
|
|
|
|
* from the given database row.
|
|
|
|
|
*
|
2008-05-22 19:48:26 +00:00
|
|
|
* @param $row object
|
2005-10-02 04:05:40 +00:00
|
|
|
* @return string
|
|
|
|
|
* @access private
|
|
|
|
|
*/
|
|
|
|
|
function openPage( $row ) {
|
|
|
|
|
$out = " <page>\n";
|
|
|
|
|
$title = Title::makeTitle( $row->page_namespace, $row->page_title );
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= ' ' . Xml::elementClean( 'title', array(), $title->getPrefixedText() ) . "\n";
|
|
|
|
|
$out .= ' ' . Xml::element( 'id', array(), strval( $row->page_id ) ) . "\n";
|
2009-07-14 21:38:43 +00:00
|
|
|
if( $row->page_is_redirect ) {
|
2009-09-18 17:34:56 +00:00
|
|
|
$out .= ' ' . Xml::element( 'redirect', array() ) . "\n";
|
2009-07-14 21:38:43 +00:00
|
|
|
}
|
2010-01-06 19:59:42 +00:00
|
|
|
if( $row->page_restrictions != '' ) {
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= ' ' . Xml::element( 'restrictions', array(),
|
2008-10-13 00:08:44 +00:00
|
|
|
strval( $row->page_restrictions ) ) . "\n";
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
2009-07-27 17:57:51 +00:00
|
|
|
|
|
|
|
|
wfRunHooks( 'XmlDumpWriterOpenPage', array( $this, &$out, $row, $title ) );
|
|
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
return $out;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
|
|
|
|
* Closes a <page> section on the output stream.
|
|
|
|
|
*
|
|
|
|
|
* @access private
|
|
|
|
|
*/
|
|
|
|
|
function closePage() {
|
|
|
|
|
return " </page>\n";
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
|
|
|
|
* Dumps a <revision> section on the output stream, with
|
|
|
|
|
* data filled in from the given database row.
|
|
|
|
|
*
|
2008-05-22 19:48:26 +00:00
|
|
|
* @param $row object
|
2005-10-02 04:05:40 +00:00
|
|
|
* @return string
|
|
|
|
|
* @access private
|
|
|
|
|
*/
|
|
|
|
|
function writeRevision( $row ) {
|
|
|
|
|
$fname = 'WikiExporter::dumpRev';
|
|
|
|
|
wfProfileIn( $fname );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
$out = " <revision>\n";
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::element( 'id', null, strval( $row->rev_id ) ) . "\n";
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2008-03-04 02:03:52 +00:00
|
|
|
$out .= $this->writeTimestamp( $row->rev_timestamp );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-06-23 06:31:46 +00:00
|
|
|
if( $row->rev_deleted & Revision::DELETED_USER ) {
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::element( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n";
|
2005-10-02 04:05:40 +00:00
|
|
|
} else {
|
2008-03-04 02:03:52 +00:00
|
|
|
$out .= $this->writeContributor( $row->rev_user, $row->rev_user_text );
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
if( $row->rev_minor_edit ) {
|
|
|
|
|
$out .= " <minor/>\n";
|
|
|
|
|
}
|
2006-06-23 06:31:46 +00:00
|
|
|
if( $row->rev_deleted & Revision::DELETED_COMMENT ) {
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::element( 'comment', array( 'deleted' => 'deleted' ) ) . "\n";
|
2006-03-16 19:04:25 +00:00
|
|
|
} elseif( $row->rev_comment != '' ) {
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::elementClean( 'comment', null, strval( $row->rev_comment ) ) . "\n";
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2009-10-15 07:08:56 +00:00
|
|
|
$text = '';
|
2006-06-23 06:31:46 +00:00
|
|
|
if( $row->rev_deleted & Revision::DELETED_TEXT ) {
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
|
2006-03-16 19:04:25 +00:00
|
|
|
} elseif( isset( $row->old_text ) ) {
|
2005-10-16 17:33:41 +00:00
|
|
|
// Raw text from the database may have invalid chars
|
|
|
|
|
$text = strval( Revision::getRevisionText( $row ) );
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::elementClean( 'text',
|
2005-10-16 17:33:41 +00:00
|
|
|
array( 'xml:space' => 'preserve' ),
|
|
|
|
|
strval( $text ) ) . "\n";
|
|
|
|
|
} else {
|
|
|
|
|
// Stub output
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::element( 'text',
|
2005-10-16 17:33:41 +00:00
|
|
|
array( 'id' => $row->rev_text_id ),
|
|
|
|
|
"" ) . "\n";
|
|
|
|
|
}
|
2009-10-15 07:08:56 +00:00
|
|
|
|
2009-07-27 17:57:51 +00:00
|
|
|
wfRunHooks( 'XmlDumpWriterWriteRevision', array( &$this, &$out, $row, $text ) );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
$out .= " </revision>\n";
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
wfProfileOut( $fname );
|
|
|
|
|
return $out;
|
|
|
|
|
}
|
2008-09-18 00:02:57 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dumps a <logitem> section on the output stream, with
|
|
|
|
|
* data filled in from the given database row.
|
|
|
|
|
*
|
|
|
|
|
* @param $row object
|
|
|
|
|
* @return string
|
|
|
|
|
* @access private
|
|
|
|
|
*/
|
|
|
|
|
function writeLogItem( $row ) {
|
|
|
|
|
$fname = 'WikiExporter::writeLogItem';
|
|
|
|
|
wfProfileIn( $fname );
|
|
|
|
|
|
|
|
|
|
$out = " <logitem>\n";
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n";
|
2008-09-18 00:02:57 +00:00
|
|
|
|
|
|
|
|
$out .= $this->writeTimestamp( $row->log_timestamp );
|
|
|
|
|
|
|
|
|
|
if( $row->log_deleted & LogPage::DELETED_USER ) {
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::element( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n";
|
2008-09-18 00:02:57 +00:00
|
|
|
} else {
|
|
|
|
|
$out .= $this->writeContributor( $row->log_user, $row->user_name );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( $row->log_deleted & LogPage::DELETED_COMMENT ) {
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::element( 'comment', array( 'deleted' => 'deleted' ) ) . "\n";
|
2008-09-18 00:02:57 +00:00
|
|
|
} elseif( $row->log_comment != '' ) {
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::elementClean( 'comment', null, strval( $row->log_comment ) ) . "\n";
|
2008-09-18 00:02:57 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::element( 'type', null, strval( $row->log_type ) ) . "\n";
|
|
|
|
|
$out .= " " . Xml::element( 'action', null, strval( $row->log_action ) ) . "\n";
|
2008-09-18 00:02:57 +00:00
|
|
|
|
|
|
|
|
if( $row->log_deleted & LogPage::DELETED_ACTION ) {
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
|
2008-09-18 00:02:57 +00:00
|
|
|
} else {
|
|
|
|
|
$title = Title::makeTitle( $row->log_namespace, $row->log_title );
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::elementClean( 'logtitle', null, $title->getPrefixedText() ) . "\n";
|
|
|
|
|
$out .= " " . Xml::elementClean( 'params',
|
2008-09-18 00:02:57 +00:00
|
|
|
array( 'xml:space' => 'preserve' ),
|
|
|
|
|
strval( $row->log_params ) ) . "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$out .= " </logitem>\n";
|
|
|
|
|
|
|
|
|
|
wfProfileOut( $fname );
|
|
|
|
|
return $out;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-04 02:03:52 +00:00
|
|
|
function writeTimestamp( $timestamp ) {
|
|
|
|
|
$ts = wfTimestamp( TS_ISO_8601, $timestamp );
|
2008-12-14 19:14:21 +00:00
|
|
|
return " " . Xml::element( 'timestamp', null, $ts ) . "\n";
|
2008-03-04 02:03:52 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-04 02:03:52 +00:00
|
|
|
function writeContributor( $id, $text ) {
|
|
|
|
|
$out = " <contributor>\n";
|
|
|
|
|
if( $id ) {
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::elementClean( 'username', null, strval( $text ) ) . "\n";
|
|
|
|
|
$out .= " " . Xml::element( 'id', null, strval( $id ) ) . "\n";
|
2008-03-04 02:03:52 +00:00
|
|
|
} else {
|
2008-12-14 19:14:21 +00:00
|
|
|
$out .= " " . Xml::elementClean( 'ip', null, strval( $text ) ) . "\n";
|
2008-03-04 02:03:52 +00:00
|
|
|
}
|
|
|
|
|
$out .= " </contributor>\n";
|
|
|
|
|
return $out;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-04 02:03:52 +00:00
|
|
|
/**
|
|
|
|
|
* Warning! This data is potentially inconsistent. :(
|
|
|
|
|
*/
|
|
|
|
|
function writeUploads( $row ) {
|
|
|
|
|
if( $row->page_namespace == NS_IMAGE ) {
|
|
|
|
|
$img = wfFindFile( $row->page_title );
|
|
|
|
|
if( $img ) {
|
|
|
|
|
$out = '';
|
|
|
|
|
foreach( array_reverse( $img->getHistory() ) as $ver ) {
|
|
|
|
|
$out .= $this->writeUpload( $ver );
|
|
|
|
|
}
|
|
|
|
|
$out .= $this->writeUpload( $img );
|
|
|
|
|
return $out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-04 02:03:52 +00:00
|
|
|
function writeUpload( $file ) {
|
|
|
|
|
return " <upload>\n" .
|
|
|
|
|
$this->writeTimestamp( $file->getTimestamp() ) .
|
|
|
|
|
$this->writeContributor( $file->getUser( 'id' ), $file->getUser( 'text' ) ) .
|
2008-12-14 19:14:21 +00:00
|
|
|
" " . Xml::elementClean( 'comment', null, $file->getDescription() ) . "\n" .
|
|
|
|
|
" " . Xml::element( 'filename', null, $file->getName() ) . "\n" .
|
|
|
|
|
" " . Xml::element( 'src', null, $file->getFullUrl() ) . "\n" .
|
|
|
|
|
" " . Xml::element( 'size', null, $file->getSize() ) . "\n" .
|
2008-03-04 02:03:52 +00:00
|
|
|
" </upload>\n";
|
|
|
|
|
}
|
2005-10-02 04:05:40 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Base class for output stream; prints to stdout or buffer or whereever.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Dump
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
|
|
|
|
class DumpOutput {
|
|
|
|
|
function writeOpenStream( $string ) {
|
|
|
|
|
$this->write( $string );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeCloseStream( $string ) {
|
|
|
|
|
$this->write( $string );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeOpenPage( $page, $string ) {
|
|
|
|
|
$this->write( $string );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeClosePage( $string ) {
|
|
|
|
|
$this->write( $string );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeRevision( $rev, $string ) {
|
|
|
|
|
$this->write( $string );
|
|
|
|
|
}
|
2008-09-18 00:02:57 +00:00
|
|
|
|
|
|
|
|
function writeLogItem( $rev, $string ) {
|
|
|
|
|
$this->write( $string );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
|
|
|
|
* Override to write to a different stream type.
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
function write( $string ) {
|
|
|
|
|
print $string;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Stream outputter to send data to a file.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Dump
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
|
|
|
|
class DumpFileOutput extends DumpOutput {
|
|
|
|
|
var $handle;
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function DumpFileOutput( $file ) {
|
|
|
|
|
$this->handle = fopen( $file, "wt" );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function write( $string ) {
|
|
|
|
|
fputs( $this->handle, $string );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Stream outputter to send data to a file via some filter program.
|
|
|
|
|
* Even if compression is available in a library, using a separate
|
|
|
|
|
* program can allow us to make use of a multi-processor system.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Dump
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
|
|
|
|
class DumpPipeOutput extends DumpFileOutput {
|
|
|
|
|
function DumpPipeOutput( $command, $file = null ) {
|
|
|
|
|
if( !is_null( $file ) ) {
|
|
|
|
|
$command .= " > " . wfEscapeShellArg( $file );
|
|
|
|
|
}
|
|
|
|
|
$this->handle = popen( $command, "w" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sends dump output via the gzip compressor.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Dump
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
|
|
|
|
class DumpGZipOutput extends DumpPipeOutput {
|
|
|
|
|
function DumpGZipOutput( $file ) {
|
|
|
|
|
parent::DumpPipeOutput( "gzip", $file );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sends dump output via the bgzip2 compressor.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Dump
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
|
|
|
|
class DumpBZip2Output extends DumpPipeOutput {
|
|
|
|
|
function DumpBZip2Output( $file ) {
|
|
|
|
|
parent::DumpPipeOutput( "bzip2", $file );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sends dump output via the p7zip compressor.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Dump
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
|
|
|
|
class Dump7ZipOutput extends DumpPipeOutput {
|
|
|
|
|
function Dump7ZipOutput( $file ) {
|
2006-01-22 07:03:03 +00:00
|
|
|
$command = "7za a -bd -si " . wfEscapeShellArg( $file );
|
2006-04-30 03:58:19 +00:00
|
|
|
// Suppress annoying useless crap from p7zip
|
|
|
|
|
// Unfortunately this could suppress real error messages too
|
2007-08-17 14:39:11 +00:00
|
|
|
$command .= ' >' . wfGetNull() . ' 2>&1';
|
2005-10-02 04:05:40 +00:00
|
|
|
parent::DumpPipeOutput( $command );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dump output filter class.
|
|
|
|
|
* This just does output filtering and streaming; XML formatting is done
|
|
|
|
|
* higher up, so be careful in what you do.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Dump
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
|
|
|
|
class DumpFilter {
|
|
|
|
|
function DumpFilter( &$sink ) {
|
|
|
|
|
$this->sink =& $sink;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeOpenStream( $string ) {
|
|
|
|
|
$this->sink->writeOpenStream( $string );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeCloseStream( $string ) {
|
|
|
|
|
$this->sink->writeCloseStream( $string );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeOpenPage( $page, $string ) {
|
|
|
|
|
$this->sendingThisPage = $this->pass( $page, $string );
|
|
|
|
|
if( $this->sendingThisPage ) {
|
|
|
|
|
$this->sink->writeOpenPage( $page, $string );
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeClosePage( $string ) {
|
|
|
|
|
if( $this->sendingThisPage ) {
|
|
|
|
|
$this->sink->writeClosePage( $string );
|
|
|
|
|
$this->sendingThisPage = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeRevision( $rev, $string ) {
|
|
|
|
|
if( $this->sendingThisPage ) {
|
|
|
|
|
$this->sink->writeRevision( $rev, $string );
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-09-18 00:02:57 +00:00
|
|
|
|
|
|
|
|
function writeLogItem( $rev, $string ) {
|
|
|
|
|
$this->sink->writeRevision( $rev, $string );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
|
|
|
|
* Override for page-based filter types.
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2006-11-29 05:45:03 +00:00
|
|
|
function pass( $page ) {
|
2005-10-02 04:05:40 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Simple dump output filter to exclude all talk pages.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Dump
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
|
|
|
|
class DumpNotalkFilter extends DumpFilter {
|
|
|
|
|
function pass( $page ) {
|
2008-03-21 23:13:34 +00:00
|
|
|
return !MWNamespace::isTalk( $page->page_namespace );
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dump output filter to include or exclude pages in a given set of namespaces.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Dump
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
|
|
|
|
class DumpNamespaceFilter extends DumpFilter {
|
|
|
|
|
var $invert = false;
|
2005-10-02 07:17:41 +00:00
|
|
|
var $namespaces = array();
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function DumpNamespaceFilter( &$sink, $param ) {
|
|
|
|
|
parent::DumpFilter( $sink );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
$constants = array(
|
|
|
|
|
"NS_MAIN" => NS_MAIN,
|
|
|
|
|
"NS_TALK" => NS_TALK,
|
|
|
|
|
"NS_USER" => NS_USER,
|
|
|
|
|
"NS_USER_TALK" => NS_USER_TALK,
|
|
|
|
|
"NS_PROJECT" => NS_PROJECT,
|
|
|
|
|
"NS_PROJECT_TALK" => NS_PROJECT_TALK,
|
2008-11-27 22:36:25 +00:00
|
|
|
"NS_FILE" => NS_FILE,
|
|
|
|
|
"NS_FILE_TALK" => NS_FILE_TALK,
|
|
|
|
|
"NS_IMAGE" => NS_IMAGE, // NS_IMAGE is an alias for NS_FILE
|
2005-10-02 04:05:40 +00:00
|
|
|
"NS_IMAGE_TALK" => NS_IMAGE_TALK,
|
|
|
|
|
"NS_MEDIAWIKI" => NS_MEDIAWIKI,
|
|
|
|
|
"NS_MEDIAWIKI_TALK" => NS_MEDIAWIKI_TALK,
|
|
|
|
|
"NS_TEMPLATE" => NS_TEMPLATE,
|
|
|
|
|
"NS_TEMPLATE_TALK" => NS_TEMPLATE_TALK,
|
|
|
|
|
"NS_HELP" => NS_HELP,
|
|
|
|
|
"NS_HELP_TALK" => NS_HELP_TALK,
|
|
|
|
|
"NS_CATEGORY" => NS_CATEGORY,
|
|
|
|
|
"NS_CATEGORY_TALK" => NS_CATEGORY_TALK );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
if( $param{0} == '!' ) {
|
|
|
|
|
$this->invert = true;
|
|
|
|
|
$param = substr( $param, 1 );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
foreach( explode( ',', $param ) as $key ) {
|
|
|
|
|
$key = trim( $key );
|
2005-10-02 07:17:41 +00:00
|
|
|
if( isset( $constants[$key] ) ) {
|
2005-10-02 04:05:40 +00:00
|
|
|
$ns = $constants[$key];
|
|
|
|
|
$this->namespaces[$ns] = true;
|
|
|
|
|
} elseif( is_numeric( $key ) ) {
|
|
|
|
|
$ns = intval( $key );
|
|
|
|
|
$this->namespaces[$ns] = true;
|
2005-10-02 07:17:41 +00:00
|
|
|
} else {
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new MWException( "Unrecognized namespace key '$key'\n" );
|
2005-10-02 04:05:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function pass( $page ) {
|
|
|
|
|
$match = isset( $this->namespaces[$page->page_namespace] );
|
|
|
|
|
return $this->invert xor $match;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dump output filter to include only the last revision in each page sequence.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Dump
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
|
|
|
|
class DumpLatestFilter extends DumpFilter {
|
|
|
|
|
var $page, $pageString, $rev, $revString;
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeOpenPage( $page, $string ) {
|
|
|
|
|
$this->page = $page;
|
|
|
|
|
$this->pageString = $string;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeClosePage( $string ) {
|
|
|
|
|
if( $this->rev ) {
|
|
|
|
|
$this->sink->writeOpenPage( $this->page, $this->pageString );
|
|
|
|
|
$this->sink->writeRevision( $this->rev, $this->revString );
|
|
|
|
|
$this->sink->writeClosePage( $string );
|
|
|
|
|
}
|
|
|
|
|
$this->rev = null;
|
|
|
|
|
$this->revString = null;
|
|
|
|
|
$this->page = null;
|
|
|
|
|
$this->pageString = null;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeRevision( $rev, $string ) {
|
|
|
|
|
if( $rev->rev_id == $this->page->page_latest ) {
|
|
|
|
|
$this->rev = $rev;
|
|
|
|
|
$this->revString = $string;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Base class for output stream; prints to stdout or buffer or whereever.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Dump
|
2005-10-02 04:05:40 +00:00
|
|
|
*/
|
|
|
|
|
class DumpMultiWriter {
|
|
|
|
|
function DumpMultiWriter( $sinks ) {
|
|
|
|
|
$this->sinks = $sinks;
|
|
|
|
|
$this->count = count( $sinks );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeOpenStream( $string ) {
|
|
|
|
|
for( $i = 0; $i < $this->count; $i++ ) {
|
|
|
|
|
$this->sinks[$i]->writeOpenStream( $string );
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeCloseStream( $string ) {
|
|
|
|
|
for( $i = 0; $i < $this->count; $i++ ) {
|
|
|
|
|
$this->sinks[$i]->writeCloseStream( $string );
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeOpenPage( $page, $string ) {
|
|
|
|
|
for( $i = 0; $i < $this->count; $i++ ) {
|
|
|
|
|
$this->sinks[$i]->writeOpenPage( $page, $string );
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeClosePage( $string ) {
|
|
|
|
|
for( $i = 0; $i < $this->count; $i++ ) {
|
|
|
|
|
$this->sinks[$i]->writeClosePage( $string );
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
function writeRevision( $rev, $string ) {
|
|
|
|
|
for( $i = 0; $i < $this->count; $i++ ) {
|
|
|
|
|
$this->sinks[$i]->writeRevision( $rev, $string );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function xmlsafe( $string ) {
|
|
|
|
|
$fname = 'xmlsafe';
|
|
|
|
|
wfProfileIn( $fname );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
/**
|
|
|
|
|
* The page may contain old data which has not been properly normalized.
|
|
|
|
|
* Invalid UTF-8 sequences or forbidden control characters will make our
|
|
|
|
|
* XML output invalid, so be sure to strip them out.
|
|
|
|
|
*/
|
|
|
|
|
$string = UtfNormal::cleanUp( $string );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-10-02 04:05:40 +00:00
|
|
|
$string = htmlspecialchars( $string );
|
|
|
|
|
wfProfileOut( $fname );
|
|
|
|
|
return $string;
|
|
|
|
|
}
|