For MediaWiki (recent comments | status changes | tags | authors | states | release notes)
Index: trunk/phase3/includes/Article.php =================================================================== --- trunk/phase3/includes/Article.php (revision 29871) +++ trunk/phase3/includes/Article.php (revision 29872) @@ -1942,7 +1942,18 @@ $wgOut->showPermissionsErrorPage( $permission_errors ); return; } + + # Hack for big sites + if( $this->isBigDeletion() ) { + $permission_errors = $this->mTitle->getUserPermissionsErrors( + 'bigdelete', $wgUser ); + if( count( $permission_errors ) > 0 ) { + $wgOut->showPermissionsErrorPage( $permission_errors ); + return; + } + } + $wgOut->setPagetitle( wfMsg( 'confirmdelete' ) ); # Better double-check that it hasn't been deleted yet! @@ -1976,6 +1987,30 @@ return $this->confirmDelete( '', $reason ); } + + /** + * @return bool whether or not the page surpasses $wgDeleteRevisionsLimit revisions + */ + function isBigDeletion() { + global $wgDeleteRevisionsLimit; + if( $wgDeleteRevisionsLimit ) { + $revCount = $this->estimateRevisionCount(); + return $revCount > $wgDeleteRevisionsLimit; + } + return false; + } + + /** + * @return int approximate revision count + */ + function estimateRevisionCount() { + $dbr = wfGetDB(); + // For an exact count... + //return $dbr->selectField( 'revision', 'COUNT(*)', + // array( 'rev_page' => $this->getId() ), __METHOD__ ); + return $dbr->estimateRowCount( 'revision', '*', + array( 'rev_page' => $this->getId() ), __METHOD__ ); + } /** * Get the last N authors Index: trunk/phase3/includes/DefaultSettings.php =================================================================== --- trunk/phase3/includes/DefaultSettings.php (revision 29871) +++ trunk/phase3/includes/DefaultSettings.php (revision 29872) @@ -1099,6 +1099,7 @@ $wgGroupPermissions['sysop']['block'] = true; $wgGroupPermissions['sysop']['createaccount'] = true; $wgGroupPermissions['sysop']['delete'] = true; +$wgGroupPermissions['sysop']['bigdelete'] = true; // can be separately configured for pages with > $wgDeleteRevisionsLimit revs $wgGroupPermissions['sysop']['deletedhistory'] = true; // can view deleted history entries, but not see or restore the text $wgGroupPermissions['sysop']['undelete'] = true; $wgGroupPermissions['sysop']['editinterface'] = true; @@ -1247,6 +1248,12 @@ */ $wgAddGroups = $wgRemoveGroups = array(); +/** + * Optional to restrict deletion of pages with higher revision counts + * to users with the 'bigdelete' permission. (Default given to sysops.) + */ +$wgDeleteRevisionsLimit = 0; + # Proxy scanner settings #