* (bug 2483) Run link updates on change via XML import
* (bug 2481) List imported pages during Special:Import
* (bug 2482) Log and RC entries for Special:Import events
+* Allow fetching all revisions from transwiki Special:Import
+* Allow fetching all revisions from Special:Export GET request
+* Disable output buffering on Special:Export; should help with streaming
+ large numbers of history items.
+* Allow setting a maximum number of revisions for history Special:Export;
+ pages with more than $wgExportMaxHistory revisions are excluded from
+ export when history is requested.
+* Fix transwiki import of pages with space in name
== Compatibility ==
* disabled on Wikimedia's sites.
*/
$wgExportAllowHistory = true;
+
+/**
+ * If set nonzero, Special:Export requests for history of pages with
+ * more revisions than this will be rejected. On some big sites things
+ * could get bogged down by very very long pages.
+ */
+$wgExportMaxHistory = 0;
+
$wgExportAllowListContributors = false ;
}
return $timestamp;
}
+
+ static function countByPageId( $db, $id ) {
+ $row = $db->selectRow( 'revision', 'COUNT(*) AS revCount',
+ array( 'rev_page' => $id ), __METHOD__ );
+ if( $row ) {
+ return $row->revCount;
+ }
+ return 0;
+ }
+
+ static function countByTitle( $db, $title ) {
+ $id = $title->getArticleId();
+ if( $id ) {
+ return Revision::countByPageId( $db, $id );
+ }
+ return 0;
+ }
}
/**
*/
function wfSpecialExport( $page = '' ) {
global $wgOut, $wgRequest, $wgExportAllowListContributors;
- global $wgExportAllowHistory;
+ global $wgExportAllowHistory, $wgExportMaxHistory;
+ $curonly = true;
if( $wgRequest->getVal( 'action' ) == 'submit') {
$page = $wgRequest->getText( 'pages' );
- if( $wgExportAllowHistory ) {
- $curonly = $wgRequest->getCheck( 'curonly' );
- } else {
- $curonly = true;
- }
- } else {
- # Pre-check the 'current version only' box in the UI
+ $curonly = $wgRequest->getCheck( 'curonly' );
+ }
+ if( $wgRequest->getCheck( 'history' ) ) {
+ $curonly = false;
+ }
+ if( !$wgExportAllowHistory ) {
+ // Override
$curonly = true;
}
if( $page != '' ) {
$wgOut->disable();
+
+ // Cancel output buffering and gzipping if set
+ // This should provide safer streaming for pages with history
+ while( $status = ob_get_status() ) {
+ ob_end_clean();
+ if( $status['name'] == 'ob_gzhandler' ) {
+ header( 'Content-Encoding:' );
+ }
+ }
header( "Content-type: application/xml; charset=utf-8" );
$pages = explode( "\n", $page );
$exporter = new WikiExporter( $db, $history );
$exporter->list_authors = $list_authors ;
$exporter->openStream();
- $exporter->pagesByName( $pages );
+
+ foreach( $pages as $page ) {
+ if( $wgExportMaxHistory && !$curonly ) {
+ $title = Title::newFromText( $page );
+ if( $title ) {
+ $count = Revision::countByTitle( $db, $title );
+ if( $count > $wgExportMaxHistory ) {
+ wfDebug( __FUNCTION__ .
+ ": Skipped $page, $count revisions too big\n" );
+ continue;
+ }
+ }
+ }
+ $exporter->pagesByName( $pages );
+ }
+
$exporter->closeStream();
return;
}
}
break;
case "interwiki":
- $interwiki = $wgRequest->getVal( "interwiki" );
+ $interwiki = $wgRequest->getVal( 'interwiki' );
+ $history = $wgRequest->getCheck( 'interwikiHistory' );
$source = ImportStreamSource::newFromInterwiki(
$interwiki,
- $wgRequest->getText( "frompage" ) );
+ $wgRequest->getText( "frompage" ),
+ $history );
break;
default:
$source = new WikiError( "Unknown import source type" );
$wgOut->addHTML( "
<fieldset>
<legend>" . wfMsgHtml('importinterwiki') . "</legend>
- <form method='post' action=\"$action\">
+ <form method='post' action=\"$action\">" .
+ $wgOut->parse( wfMsg( 'import-interwiki-text' ) ) . "
<input type='hidden' name='action' value='submit' />
<input type='hidden' name='source' value='interwiki' />
- <select name='interwiki'>
-" );
+ <table>
+ <tr>
+ <td>
+ <select name='interwiki'>" );
foreach( $wgImportSources as $interwiki ) {
$iw = htmlspecialchars( $interwiki );
$wgOut->addHTML( "<option value=\"$iw\">$iw</option>\n" );
}
$wgOut->addHTML( "
- </select>
- <input name='frompage' />
- <input type='submit' />
+ </select>
+ </td>
+ <td>" .
+ wfInput( 'frompage', 40 ) .
+ "</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>" .
+ wfCheckLabel( wfMsg( 'import-interwiki-history' ),
+ 'interwikiHistory', 'interwikiHistory', true ) .
+ "</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>" .
+ wfSubmitButton( wfMsg( 'import-interwiki-submit' ) ) .
+ "</td>
+ </tr>
+ </table>
</form>
</fieldset>
" );
}
function newFromURL( $url ) {
+ wfDebug( __METHOD__ . ": opening $url\n" );
# fopen-wrappers are normally turned off for security.
ini_set( "allow_url_fopen", true );
$ret = ImportStreamSource::newFromFile( $url );
return $ret;
}
- function newFromInterwiki( $interwiki, $page ) {
+ function newFromInterwiki( $interwiki, $page, $history=false ) {
$base = Title::getInterwikiLink( $interwiki );
- if( empty( $base ) ) {
+ $link = Title::newFromText( "$interwiki:Special:Export/$page" );
+ if( empty( $base ) || empty( $link ) ) {
return new WikiError( 'Bad interwiki link' );
} else {
- $import = wfUrlencode( "Special:Export/$page" );
- $url = str_replace( "$1", $import, $base );
+ $params = $history ? 'history=1' : '';
+ $url = $link->getFullUrl( $params );
return ImportStreamSource::newFromURL( $url );
}
}
# Special:Import
'import' => 'Import pages',
'importinterwiki' => 'Transwiki import',
+'import-interwiki-text' => 'Select a wiki and page title to import.
+Revision dates and editors\' names will be preserved.
+All transwiki import actions are logged at the [[Special:Log/import|import log]].',
+'import-interwiki-history' => 'Copy all history versions for this page',
+'import-interwiki-submit' => 'Import',
'importtext' => 'Please export the file from the source wiki using the Special:Export utility, save it to your disk and upload it here.',
'importstart' => "Importing pages...",
'importnopages' => "No pages to import.",