Followup to r46951 and friends: add $wgExportMaxLinkDepth, defaulting to 0.
If set to non-zero, this specifies the maximum link depth that will be followed for exports. Remember "6 degrees of separation", this could easily kill on a site like Wikipedia. :)
This commit is contained in:
parent
3d3c0b90e3
commit
062158904b
2 changed files with 29 additions and 3 deletions
|
|
@ -2269,6 +2269,15 @@ $wgExportMaxHistory = 0;
|
|||
|
||||
$wgExportAllowListContributors = false ;
|
||||
|
||||
/**
|
||||
* If non-zero, Special:Export accepts a "pagelink-depth" parameter
|
||||
* up to this specified level, which will cause it to include all
|
||||
* pages linked to from the pages you specify. Since this number
|
||||
* can become *insanely large* and could easily break your wiki,
|
||||
* it's disabled by default for now.
|
||||
*/
|
||||
$wgExportMaxLinkDepth = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Edits matching these regular expressions in body text or edit summary
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class SpecialExport extends SpecialPage {
|
|||
|
||||
public function execute( $par ) {
|
||||
global $wgOut, $wgRequest, $wgSitename, $wgExportAllowListContributors;
|
||||
global $wgExportAllowHistory, $wgExportMaxHistory;
|
||||
global $wgExportAllowHistory, $wgExportMaxHistory, $wgExportMaxLinkDepth;
|
||||
|
||||
$this->setHeaders();
|
||||
$this->outputHeader();
|
||||
|
|
@ -42,7 +42,8 @@ class SpecialExport extends SpecialPage {
|
|||
$this->doExport = false;
|
||||
$this->templates = $wgRequest->getCheck( 'templates' );
|
||||
$this->images = $wgRequest->getCheck( 'images' ); // Doesn't do anything yet
|
||||
$this->pageLinkDepth = $wgRequest->getIntOrNull( 'pagelink-depth' );
|
||||
$this->pageLinkDepth = $this->validateLinkDepth(
|
||||
$wgRequest->getIntOrNull( 'pagelink-depth' ) );
|
||||
|
||||
if ( $wgRequest->getCheck( 'addcat' ) ) {
|
||||
$page = $wgRequest->getText( 'pages' );
|
||||
|
|
@ -144,7 +145,9 @@ class SpecialExport extends SpecialPage {
|
|||
$wgOut->addHTML( wfMsgExt( 'exportnohistory', 'parse' ) );
|
||||
}
|
||||
$form .= Xml::checkLabel( wfMsg( 'export-templates' ), 'templates', 'wpExportTemplates', false ) . '<br />';
|
||||
$form .= Xml::inputLabel( wfMsg( 'export-pagelinks' ), 'pagelink-depth', 'pagelink-depth', 20, 0 ) . '<br />';
|
||||
if( $wgExportMaxLinkDepth ) {
|
||||
$form .= Xml::inputLabel( wfMsg( 'export-pagelinks' ), 'pagelink-depth', 'pagelink-depth', 20, 0 ) . '<br />';
|
||||
}
|
||||
// Enable this when we can do something useful exporting/importing image information. :)
|
||||
//$form .= Xml::checkLabel( wfMsg( 'export-images' ), 'images', 'wpExportImages', false ) . '<br />';
|
||||
$form .= Xml::checkLabel( wfMsg( 'export-download' ), 'wpDownload', 'wpDownload', true ) . '<br />';
|
||||
|
|
@ -270,6 +273,20 @@ class SpecialExport extends SpecialPage {
|
|||
array( 'page_id=tl_from' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate link depth setting, if available.
|
||||
*/
|
||||
private function validateLinkDepth( $depth ) {
|
||||
global $wgExportMaxLinkDepth;
|
||||
if( $depth < 0 ) {
|
||||
return 0;
|
||||
}
|
||||
if( $depth > $wgExportMaxLinkDepth ) {
|
||||
return $wgExportMaxLinkDepth;
|
||||
}
|
||||
return intval( $depth );
|
||||
}
|
||||
|
||||
/** Expand a list of pages to include pages linked to from that page. */
|
||||
private function getPageLinks( $inputPages, $pageSet, $depth ) {
|
||||
for( $depth=$depth; $depth>0; --$depth ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue