r29872 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r29871‎ | r29872 | r29873 >
Date:23:08, 16 January 2008
Author:brion
Status:old
Tags:
Comment:
Quick hack in: $wgDeleteRevisionsLimit and 'bigdelete' permission.
Should keep us from the couple-of-times-yearly "oops someone deleted the sandbox" fun.
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -1942,7 +1942,18 @@
19431943 $wgOut->showPermissionsErrorPage( $permission_errors );
19441944 return;
19451945 }
 1946+
 1947+ # Hack for big sites
 1948+ if( $this->isBigDeletion() ) {
 1949+ $permission_errors = $this->mTitle->getUserPermissionsErrors(
 1950+ 'bigdelete', $wgUser );
19461951
 1952+ if( count( $permission_errors ) > 0 ) {
 1953+ $wgOut->showPermissionsErrorPage( $permission_errors );
 1954+ return;
 1955+ }
 1956+ }
 1957+
19471958 $wgOut->setPagetitle( wfMsg( 'confirmdelete' ) );
19481959
19491960 # Better double-check that it hasn't been deleted yet!
@@ -1976,6 +1987,30 @@
19771988
19781989 return $this->confirmDelete( '', $reason );
19791990 }
 1991+
 1992+ /**
 1993+ * @return bool whether or not the page surpasses $wgDeleteRevisionsLimit revisions
 1994+ */
 1995+ function isBigDeletion() {
 1996+ global $wgDeleteRevisionsLimit;
 1997+ if( $wgDeleteRevisionsLimit ) {
 1998+ $revCount = $this->estimateRevisionCount();
 1999+ return $revCount > $wgDeleteRevisionsLimit;
 2000+ }
 2001+ return false;
 2002+ }
 2003+
 2004+ /**
 2005+ * @return int approximate revision count
 2006+ */
 2007+ function estimateRevisionCount() {
 2008+ $dbr = wfGetDB();
 2009+ // For an exact count...
 2010+ //return $dbr->selectField( 'revision', 'COUNT(*)',
 2011+ // array( 'rev_page' => $this->getId() ), __METHOD__ );
 2012+ return $dbr->estimateRowCount( 'revision', '*',
 2013+ array( 'rev_page' => $this->getId() ), __METHOD__ );
 2014+ }
19802015
19812016 /**
19822017 * Get the last N authors
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1099,6 +1099,7 @@
11001100 $wgGroupPermissions['sysop']['block'] = true;
11011101 $wgGroupPermissions['sysop']['createaccount'] = true;
11021102 $wgGroupPermissions['sysop']['delete'] = true;
 1103+$wgGroupPermissions['sysop']['bigdelete'] = true; // can be separately configured for pages with > $wgDeleteRevisionsLimit revs
11031104 $wgGroupPermissions['sysop']['deletedhistory'] = true; // can view deleted history entries, but not see or restore the text
11041105 $wgGroupPermissions['sysop']['undelete'] = true;
11051106 $wgGroupPermissions['sysop']['editinterface'] = true;
@@ -1247,6 +1248,12 @@
12481249 */
12491250 $wgAddGroups = $wgRemoveGroups = array();
12501251
 1252+/**
 1253+ * Optional to restrict deletion of pages with higher revision counts
 1254+ * to users with the 'bigdelete' permission. (Default given to sysops.)
 1255+ */
 1256+$wgDeleteRevisionsLimit = 0;
 1257+
12511258 # Proxy scanner settings
12521259 #
12531260

Status & tagging log