Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2603
pat2
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 9:04 PM
2014-11-21 21:04:05 (UTC+0)
Size
3 KB
Referenced Files
None
Subscribers
None
pat2
View Options
--- includes/Export.php.1.8 2006-02-02 14:31:06.000000000 -0500
+++ /proc/self/fd/63 2006-02-02 18:11:47.580463944 -0500
@@ -27,6 +27,7 @@
define( 'MW_EXPORT_FULL', 0 );
define( 'MW_EXPORT_CURRENT', 1 );
+define( 'MW_EXPORT_OLDIDS', 2 );
define( 'MW_EXPORT_BUFFER', 0 );
define( 'MW_EXPORT_STREAM', 1 );
@@ -48,7 +49,7 @@
* main query is still running.
*
* @param Database $db
- * @param int $history one of MW_EXPORT_FULL or MW_EXPORT_CURRENT
+ * @param int $history one of MW_EXPORT_FULL, MW_EXPORT_CURRENT or MW_EXPORT_OLDIDS
* @param int $buffer one of MW_EXPORT_BUFFER or MW_EXPORT_STREAM
*/
function WikiExporter( &$db, $history = MW_EXPORT_CURRENT,
@@ -107,15 +108,47 @@
}
/**
- * @param Title $title
+ * @param str $oldid
+ */
+ function pageById( $oldid ) {
+ if ( $this->history != MW_EXPORT_OLDIDS ) {
+ return new WikiError( "Cannot use pageById in this history mode" );
+ }
+
+ if ( $oldid && intval( $oldid ) ) {
+ $cond='rev_id=' . intval( $oldid );
+ return $this->dumpFrom( $cond );
+ }
+ return new WikiError( "Can't export invalid id '{$oldid}'" );
+ }
+
+ /**
+ * @param Title $title
*/
function pageByTitle( $title ) {
- return $this->dumpFrom(
- 'page_namespace=' . $title->getNamespace() .
- ' AND page_title=' . $this->db->addQuotes( $title->getDbKey() ) );
+ $cond='';
+ switch ( $this->history ) {
+ case MW_EXPORT_FULL:
+ case MW_EXPORT_CURRENT:
+ $cond='page_namespace=' . $title->getNamespace() .
+ ' AND page_title=' . $this->db->addQuotes( $title->getDbKey() );
+ break;
+ case MW_EXPORT_OLDIDS:
+ return new WikiError( "Can't use pageByTitle in this history mode" );
+ default:
+ return new WikiError( "Unknown history mode" );
+ }
+ return $this->dumpFrom( $cond );
}
+ /**
+ * @param str $name Page name or revision ID number ( in MW_EXPORT_OLDIDS mode )
+ */
function pageByName( $name ) {
+ if ( $this->history == MW_EXPORT_OLDIDS ) {
+ return $this->pageById( $name );
+ }
+
$title = Title::newFromText( $name );
if( is_null( $title ) ) {
return new WikiError( "Can't export invalid title" );
@@ -124,6 +157,9 @@
}
}
+ /**
+ * @param str $names List of '\n'-separated page names
+ */
function pagesByName( $names ) {
foreach( $names as $name ) {
$this->pageByName( $name );
@@ -132,7 +168,10 @@
// -------------------- private implementation below --------------------
-
+
+ /**
+ * @param str $cond sql condition
+ */
function dumpFrom( $cond = '' ) {
$fname = 'WikiExporter::dumpFrom';
wfProfileIn( $fname );
@@ -141,11 +180,15 @@
$revision = $this->db->tableName( 'revision' );
$text = $this->db->tableName( 'text' );
- if( $this->history == MW_EXPORT_FULL ) {
- $join = 'page_id=rev_page';
- } elseif( $this->history == MW_EXPORT_CURRENT ) {
+ switch ( $this->history ) {
+ case MW_EXPORT_FULL:
+ case MW_EXPORT_OLDIDS:
+ $join = 'page_id=rev_page';
+ break;
+ case MW_EXPORT_CURRENT:
$join = 'page_id=rev_page AND page_latest=rev_id';
- } else {
+ break;
+ default:
wfProfileOut( $fname );
return new WikiError( "$fname given invalid history dump type." );
}
--- includes/SpecialExport.php.1.47 2006-02-02 14:30:38.000000000 -0500
+++ /proc/self/fd/63 2006-02-02 18:11:47.636455432 -0500
@@ -35,6 +35,7 @@
if( $wgRequest->getVal( 'action' ) == 'submit') {
$page = $wgRequest->getText( 'pages' );
+ $oldids = $wgRequest->getCheck( 'oldids' );
if( $wgExportAllowHistory ) {
$curonly = $wgRequest->getCheck( 'curonly' );
} else {
@@ -51,7 +52,7 @@
$pages = explode( "\n", $page );
$db =& wfGetDB( DB_SLAVE );
- $history = $curonly ? MW_EXPORT_CURRENT : MW_EXPORT_FULL;
+ $history = $oldids ? MW_EXPORT_OLDIDS : ( $curonly ? MW_EXPORT_CURRENT : MW_EXPORT_FULL );
$exporter = new WikiExporter( $db, $history );
$exporter->openStream();
$exporter->pagesByName( $pages );
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2178
Default Alt Text
pat2 (3 KB)
Attached To
Mode
T6837: Export specified revisions of a page
Attached
Detach File
Event Timeline
Log In to Comment