From: Brion Vibber Date: Wed, 18 Feb 2009 00:48:39 +0000 (+0000) Subject: Followup to r46951 and friends: add $wgExportMaxLinkDepth, defaulting to 0. X-Git-Tag: 1.31.0-rc.0~42824 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=062158904b46d81784b95e65069ccd3704db10db;p=lhc%2Fweb%2Fwiklou.git 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. :) --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 6d37c88a59..34adb07e1f 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 diff --git a/includes/specials/SpecialExport.php b/includes/specials/SpecialExport.php index 9005cf7ce8..4f0d186a7c 100644 --- a/includes/specials/SpecialExport.php +++ b/includes/specials/SpecialExport.php @@ -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 ) . '
'; - $form .= Xml::inputLabel( wfMsg( 'export-pagelinks' ), 'pagelink-depth', 'pagelink-depth', 20, 0 ) . '
'; + if( $wgExportMaxLinkDepth ) { + $form .= Xml::inputLabel( wfMsg( 'export-pagelinks' ), 'pagelink-depth', 'pagelink-depth', 20, 0 ) . '
'; + } // Enable this when we can do something useful exporting/importing image information. :) //$form .= Xml::checkLabel( wfMsg( 'export-images' ), 'images', 'wpExportImages', false ) . '
'; $form .= Xml::checkLabel( wfMsg( 'export-download' ), 'wpDownload', 'wpDownload', true ) . '
'; @@ -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 ) {