X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FExport.php;h=b4f28be209328a40c832505e10561c761867992e;hb=3629f272c403ed3addd067a5143a5be84b18150a;hp=b6e5041b8c52bc6df555f8ecbf3bf5cfe1384e15;hpb=61fc5428c1bf605d9724e81e66baea8221ddce6d;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/Export.php b/includes/Export.php
index b6e5041b8c..b4f28be209 100644
--- a/includes/Export.php
+++ b/includes/Export.php
@@ -55,6 +55,7 @@ class WikiExporter {
* limit: maximum number of rows to return
* dir: "asc" or "desc" timestamp order
* @param $buffer Int: one of WikiExporter::BUFFER or WikiExporter::STREAM
+ * @param $text Int: one of WikiExporter::TEXT or WikiExporter::STUB
*/
function __construct( &$db, $history = WikiExporter::CURRENT,
$buffer = WikiExporter::BUFFER, $text = WikiExporter::TEXT ) {
@@ -151,15 +152,14 @@ class WikiExporter {
# Not called by default (depends on $this->list_authors)
# Can be set by Special:Export when not exporting whole history
protected function do_list_authors( $page , $revision , $cond ) {
- $fname = "do_list_authors" ;
- wfProfileIn( $fname );
+ wfProfileIn( __METHOD__ );
$this->author_list = "";
//rev_deleted
$nothidden = '('.$this->db->bitAnd('rev_deleted', Revision::DELETED_USER) . ') = 0';
$sql = "SELECT DISTINCT rev_user_text,rev_user FROM {$page},{$revision}
WHERE page_id=rev_page AND $nothidden AND " . $cond ;
- $result = $this->db->query( $sql, $fname );
+ $result = $this->db->query( $sql, __METHOD__ );
$resultset = $this->db->resultObject( $result );
while( $row = $resultset->fetchObject() ) {
$this->author_list .= "" .
@@ -171,7 +171,7 @@ class WikiExporter {
"" .
"";
}
- wfProfileOut( $fname );
+ wfProfileOut( __METHOD__ );
$this->author_list .= "";
}
@@ -207,24 +207,8 @@ class WikiExporter {
$opts = array( 'ORDER BY' => 'page_id ASC' );
$opts['USE INDEX'] = array();
$join = array();
- # Latest revision dumps...
- if( $this->history & WikiExporter::CURRENT ) {
- 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');
- # "Stable" revision dumps...
- } elseif( $this->history & WikiExporter::STABLE ) {
- # 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." );
- }
- # Time offset/limit for all pages/history...
- } elseif( is_array( $this->history ) ) {
+ if( is_array( $this->history ) ) {
+ # Time offset/limit for all pages/history...
$revJoin = 'page_id=rev_page';
# Set time order
if( $this->history['dir'] == 'asc' ) {
@@ -244,11 +228,27 @@ class WikiExporter {
if( !empty( $this->history['limit'] ) ) {
$opts['LIMIT'] = intval( $this->history['limit'] );
}
- # Full history dumps...
} elseif( $this->history & WikiExporter::FULL ) {
+ # Full history dumps...
$join['revision'] = array('INNER JOIN','page_id=rev_page');
- # Uknown history specification parameter?
+ } 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." );
+ }
} else {
+ # Uknown history specification parameter?
wfProfileOut( __METHOD__ );
return new WikiError( __METHOD__." given invalid history dump type." );
}
@@ -348,7 +348,7 @@ class XmlDumpWriter {
* @return string
*/
function schemaVersion() {
- return "0.3"; // FIXME: upgrade to 0.4 when updated XSD is ready, for the revision deletion bits
+ return "0.4";
}
/**
@@ -362,7 +362,7 @@ class XmlDumpWriter {
* @return string
*/
function openStream() {
- global $wgContLanguageCode;
+ global $wgLanguageCode;
$ver = $this->schemaVersion();
return Xml::element( 'mediawiki', array(
'xmlns' => "http://www.mediawiki.org/xml/export-$ver/",
@@ -370,7 +370,7 @@ class XmlDumpWriter {
'xsi:schemaLocation' => "http://www.mediawiki.org/xml/export-$ver/ " .
"http://www.mediawiki.org/xml/export-$ver.xsd",
'version' => $ver,
- 'xml:lang' => $wgContLanguageCode ),
+ 'xml:lang' => $wgLanguageCode ),
null ) .
"\n" .
$this->siteInfo();
@@ -413,7 +413,11 @@ class XmlDumpWriter {
global $wgContLang;
$spaces = "\n";
foreach( $wgContLang->getFormattedNamespaces() as $ns => $title ) {
- $spaces .= ' ' . Xml::element( 'namespace', array( 'key' => $ns ), $title ) . "\n";
+ $spaces .= ' ' .
+ Xml::element( 'namespace',
+ array( 'key' => $ns,
+ 'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
+ ), $title ) . "\n";
}
$spaces .= " ";
return $spaces;
@@ -442,9 +446,9 @@ class XmlDumpWriter {
$out .= ' ' . Xml::elementClean( 'title', array(), $title->getPrefixedText() ) . "\n";
$out .= ' ' . Xml::element( 'id', array(), strval( $row->page_id ) ) . "\n";
if( $row->page_is_redirect ) {
- $out .= ' ' . Xml::element( 'redirect', array() ). "\n";
+ $out .= ' ' . Xml::element( 'redirect', array() ) . "\n";
}
- if( '' != $row->page_restrictions ) {
+ if( $row->page_restrictions != '' ) {
$out .= ' ' . Xml::element( 'restrictions', array(),
strval( $row->page_restrictions ) ) . "\n";
}
@@ -472,8 +476,7 @@ class XmlDumpWriter {
* @access private
*/
function writeRevision( $row ) {
- $fname = 'WikiExporter::dumpRev';
- wfProfileIn( $fname );
+ wfProfileIn( __METHOD__ );
$out = " \n";
$out .= " " . Xml::element( 'id', null, strval( $row->rev_id ) ) . "\n";
@@ -495,6 +498,7 @@ class XmlDumpWriter {
$out .= " " . Xml::elementClean( 'comment', null, strval( $row->rev_comment ) ) . "\n";
}
+ $text = '';
if( $row->rev_deleted & Revision::DELETED_TEXT ) {
$out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
} elseif( isset( $row->old_text ) ) {
@@ -509,12 +513,12 @@ class XmlDumpWriter {
array( 'id' => $row->rev_text_id ),
"" ) . "\n";
}
-
+
wfRunHooks( 'XmlDumpWriterWriteRevision', array( &$this, &$out, $row, $text ) );
$out .= " \n";
- wfProfileOut( $fname );
+ wfProfileOut( __METHOD__ );
return $out;
}
@@ -527,8 +531,7 @@ class XmlDumpWriter {
* @access private
*/
function writeLogItem( $row ) {
- $fname = 'WikiExporter::writeLogItem';
- wfProfileIn( $fname );
+ wfProfileIn( __METHOD__ );
$out = " \n";
$out .= " " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n";
@@ -562,7 +565,7 @@ class XmlDumpWriter {
$out .= " \n";
- wfProfileOut( $fname );
+ wfProfileOut( __METHOD__ );
return $out;
}
@@ -660,7 +663,7 @@ class DumpOutput {
class DumpFileOutput extends DumpOutput {
var $handle;
- function DumpFileOutput( $file ) {
+ function __construct( $file ) {
$this->handle = fopen( $file, "wt" );
}
@@ -676,7 +679,7 @@ class DumpFileOutput extends DumpOutput {
* @ingroup Dump
*/
class DumpPipeOutput extends DumpFileOutput {
- function DumpPipeOutput( $command, $file = null ) {
+ function __construct( $command, $file = null ) {
if( !is_null( $file ) ) {
$command .= " > " . wfEscapeShellArg( $file );
}
@@ -689,8 +692,8 @@ class DumpPipeOutput extends DumpFileOutput {
* @ingroup Dump
*/
class DumpGZipOutput extends DumpPipeOutput {
- function DumpGZipOutput( $file ) {
- parent::DumpPipeOutput( "gzip", $file );
+ function __construct( $file ) {
+ parent::__construct( "gzip", $file );
}
}
@@ -699,8 +702,8 @@ class DumpGZipOutput extends DumpPipeOutput {
* @ingroup Dump
*/
class DumpBZip2Output extends DumpPipeOutput {
- function DumpBZip2Output( $file ) {
- parent::DumpPipeOutput( "bzip2", $file );
+ function __construct( $file ) {
+ parent::__construct( "bzip2", $file );
}
}
@@ -709,12 +712,12 @@ class DumpBZip2Output extends DumpPipeOutput {
* @ingroup Dump
*/
class Dump7ZipOutput extends DumpPipeOutput {
- function Dump7ZipOutput( $file ) {
+ function __construct( $file ) {
$command = "7za a -bd -si " . wfEscapeShellArg( $file );
// Suppress annoying useless crap from p7zip
// Unfortunately this could suppress real error messages too
$command .= ' >' . wfGetNull() . ' 2>&1';
- parent::DumpPipeOutput( $command );
+ parent::__construct( $command );
}
}
@@ -727,7 +730,7 @@ class Dump7ZipOutput extends DumpPipeOutput {
* @ingroup Dump
*/
class DumpFilter {
- function DumpFilter( &$sink ) {
+ function __construct( &$sink ) {
$this->sink =& $sink;
}
@@ -790,8 +793,8 @@ class DumpNamespaceFilter extends DumpFilter {
var $invert = false;
var $namespaces = array();
- function DumpNamespaceFilter( &$sink, $param ) {
- parent::DumpFilter( $sink );
+ function __construct( &$sink, $param ) {
+ parent::__construct( $sink );
$constants = array(
"NS_MAIN" => NS_MAIN,
@@ -876,7 +879,7 @@ class DumpLatestFilter extends DumpFilter {
* @ingroup Dump
*/
class DumpMultiWriter {
- function DumpMultiWriter( $sinks ) {
+ function __construct( $sinks ) {
$this->sinks = $sinks;
$this->count = count( $sinks );
}
@@ -913,8 +916,7 @@ class DumpMultiWriter {
}
function xmlsafe( $string ) {
- $fname = 'xmlsafe';
- wfProfileIn( $fname );
+ wfProfileIn( __FUNCTION__ );
/**
* The page may contain old data which has not been properly normalized.
@@ -924,6 +926,6 @@ function xmlsafe( $string ) {
$string = UtfNormal::cleanUp( $string );
$string = htmlspecialchars( $string );
- wfProfileOut( $fname );
+ wfProfileOut( __FUNCTION__ );
return $string;
}