| Index: trunk/phase3/includes/Article.php |
| — | — | @@ -1942,7 +1942,18 @@ |
| 1943 | 1943 | $wgOut->showPermissionsErrorPage( $permission_errors ); |
| 1944 | 1944 | return; |
| 1945 | 1945 | } |
| | 1946 | + |
| | 1947 | + # Hack for big sites |
| | 1948 | + if( $this->isBigDeletion() ) { |
| | 1949 | + $permission_errors = $this->mTitle->getUserPermissionsErrors( |
| | 1950 | + 'bigdelete', $wgUser ); |
| 1946 | 1951 | |
| | 1952 | + if( count( $permission_errors ) > 0 ) { |
| | 1953 | + $wgOut->showPermissionsErrorPage( $permission_errors ); |
| | 1954 | + return; |
| | 1955 | + } |
| | 1956 | + } |
| | 1957 | + |
| 1947 | 1958 | $wgOut->setPagetitle( wfMsg( 'confirmdelete' ) ); |
| 1948 | 1959 | |
| 1949 | 1960 | # Better double-check that it hasn't been deleted yet! |
| — | — | @@ -1976,6 +1987,30 @@ |
| 1977 | 1988 | |
| 1978 | 1989 | return $this->confirmDelete( '', $reason ); |
| 1979 | 1990 | } |
| | 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 | + } |
| 1980 | 2015 | |
| 1981 | 2016 | /** |
| 1982 | 2017 | * Get the last N authors |
| Index: trunk/phase3/includes/DefaultSettings.php |
| — | — | @@ -1099,6 +1099,7 @@ |
| 1100 | 1100 | $wgGroupPermissions['sysop']['block'] = true; |
| 1101 | 1101 | $wgGroupPermissions['sysop']['createaccount'] = true; |
| 1102 | 1102 | $wgGroupPermissions['sysop']['delete'] = true; |
| | 1103 | +$wgGroupPermissions['sysop']['bigdelete'] = true; // can be separately configured for pages with > $wgDeleteRevisionsLimit revs |
| 1103 | 1104 | $wgGroupPermissions['sysop']['deletedhistory'] = true; // can view deleted history entries, but not see or restore the text |
| 1104 | 1105 | $wgGroupPermissions['sysop']['undelete'] = true; |
| 1105 | 1106 | $wgGroupPermissions['sysop']['editinterface'] = true; |
| — | — | @@ -1247,6 +1248,12 @@ |
| 1248 | 1249 | */ |
| 1249 | 1250 | $wgAddGroups = $wgRemoveGroups = array(); |
| 1250 | 1251 | |
| | 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 | + |
| 1251 | 1258 | # Proxy scanner settings |
| 1252 | 1259 | # |
| 1253 | 1260 | |