Index: trunk/phase3/includes/Article.php |
— | — | @@ -1289,18 +1289,6 @@ |
1290 | 1290 | return; |
1291 | 1291 | } |
1292 | 1292 | |
1293 | | - # Hack for big sites |
1294 | | - $bigHistory = $this->mPage->isBigDeletion(); |
1295 | | - if ( $bigHistory && !$title->userCan( 'bigdelete' ) ) { |
1296 | | - global $wgDeleteRevisionsLimit; |
1297 | | - |
1298 | | - $wgOut->setPageTitle( wfMessage( 'cannotdelete-title', $title->getPrefixedText() ) ); |
1299 | | - $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n", |
1300 | | - array( 'delete-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) ); |
1301 | | - |
1302 | | - return; |
1303 | | - } |
1304 | | - |
1305 | 1293 | $deleteReasonList = $wgRequest->getText( 'wpDeleteReasonList', 'other' ); |
1306 | 1294 | $deleteReason = $wgRequest->getText( 'wpReason' ); |
1307 | 1295 | |
— | — | @@ -1338,7 +1326,7 @@ |
1339 | 1327 | |
1340 | 1328 | // If the page has a history, insert a warning |
1341 | 1329 | if ( $hasHistory ) { |
1342 | | - $revisions = $this->mPage->estimateRevisionCount(); |
| 1330 | + $revisions = $this->mTitle->estimateRevisionCount(); |
1343 | 1331 | // @todo FIXME: i18n issue/patchwork message |
1344 | 1332 | $wgOut->addHTML( '<strong class="mw-delete-warning-revisions">' . |
1345 | 1333 | wfMsgExt( 'historywarning', array( 'parseinline' ), $wgLang->formatNum( $revisions ) ) . |
Index: trunk/phase3/includes/api/ApiDelete.php |
— | — | @@ -112,11 +112,6 @@ |
113 | 113 | * @return Title::getUserPermissionsErrors()-like array |
114 | 114 | */ |
115 | 115 | public static function delete( Page $page, User $user, $token, &$reason = null ) { |
116 | | - if ( $page->isBigDeletion() && !$user->isAllowed( 'bigdelete' ) ) { |
117 | | - global $wgDeleteRevisionsLimit; |
118 | | - return array( array( 'delete-toobig', $wgDeleteRevisionsLimit ) ); |
119 | | - } |
120 | | - |
121 | 116 | $title = $page->getTitle(); |
122 | 117 | $errors = self::getPermissionsError( $title, $user, $token ); |
123 | 118 | if ( count( $errors ) ) { |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -64,6 +64,7 @@ |
65 | 65 | var $mArticleID = -1; // /< Article ID, fetched from the link cache on demand |
66 | 66 | var $mLatestID = false; // /< ID of most recent revision |
67 | 67 | var $mCounter = -1; // /< Number of times this page has been viewed (-1 means "not loaded") |
| 68 | + private $mEstimateRevisions; // /< Estimated number of revisions; null of not loaded |
68 | 69 | var $mRestrictions = array(); // /< Array of groups allowed to edit this article |
69 | 70 | var $mOldRestrictions = false; |
70 | 71 | var $mCascadeRestriction; ///< Cascade restrictions on this page to included templates and images? |
— | — | @@ -1843,6 +1844,8 @@ |
1844 | 1845 | * @return Array list of errors |
1845 | 1846 | */ |
1846 | 1847 | private function checkActionPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) { |
| 1848 | + global $wgDeleteRevisionsLimit, $wgLang; |
| 1849 | + |
1847 | 1850 | if ( $action == 'protect' ) { |
1848 | 1851 | if ( count( $this->getUserPermissionsErrorsInternal( 'edit', $user, $doExpensiveQueries, true ) ) ) { |
1849 | 1852 | // If they can't edit, they shouldn't protect. |
— | — | @@ -1875,6 +1878,12 @@ |
1876 | 1879 | } elseif ( !$this->isMovable() ) { |
1877 | 1880 | $errors[] = array( 'immobile-target-page' ); |
1878 | 1881 | } |
| 1882 | + } elseif ( $action == 'delete' ) { |
| 1883 | + if ( $doExpensiveQueries && $wgDeleteRevisionsLimit |
| 1884 | + && !$this->userCan( 'bigdelete', $user ) && $this->isBigDeletion() ) |
| 1885 | + { |
| 1886 | + $errors[] = array( 'delete-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ); |
| 1887 | + } |
1879 | 1888 | } |
1880 | 1889 | return $errors; |
1881 | 1890 | } |
— | — | @@ -2887,6 +2896,7 @@ |
2888 | 2897 | $this->mLength = -1; |
2889 | 2898 | $this->mLatestID = false; |
2890 | 2899 | $this->mCounter = -1; |
| 2900 | + $this->mEstimateRevisions = null; |
2891 | 2901 | } |
2892 | 2902 | |
2893 | 2903 | /** |
— | — | @@ -4001,6 +4011,41 @@ |
4002 | 4012 | } |
4003 | 4013 | |
4004 | 4014 | /** |
| 4015 | + * Check whether the number of revisions of this page surpasses $wgDeleteRevisionsLimit |
| 4016 | + * |
| 4017 | + * @return bool |
| 4018 | + */ |
| 4019 | + public function isBigDeletion() { |
| 4020 | + global $wgDeleteRevisionsLimit; |
| 4021 | + |
| 4022 | + if ( !$wgDeleteRevisionsLimit ) { |
| 4023 | + return false; |
| 4024 | + } |
| 4025 | + |
| 4026 | + $revCount = $this->estimateRevisionCount(); |
| 4027 | + return $revCount > $wgDeleteRevisionsLimit; |
| 4028 | + } |
| 4029 | + |
| 4030 | + /** |
| 4031 | + * Get the approximate revision count of this page. |
| 4032 | + * |
| 4033 | + * @return int |
| 4034 | + */ |
| 4035 | + public function estimateRevisionCount() { |
| 4036 | + if ( !$this->exists() ) { |
| 4037 | + return 0; |
| 4038 | + } |
| 4039 | + |
| 4040 | + if ( $this->mEstimateRevisions === null ) { |
| 4041 | + $dbr = wfGetDB( DB_SLAVE ); |
| 4042 | + $this->mEstimateRevisions = $dbr->estimateRowCount( 'revision', '*', |
| 4043 | + array( 'rev_page' => $this->getArticleId() ), __METHOD__ ); |
| 4044 | + } |
| 4045 | + |
| 4046 | + return $this->mEstimateRevisions; |
| 4047 | + } |
| 4048 | + |
| 4049 | + /** |
4005 | 4050 | * Get the number of revisions between the given revision. |
4006 | 4051 | * Used for diffs and other things that really need it. |
4007 | 4052 | * |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -1560,27 +1560,25 @@ |
1561 | 1561 | } |
1562 | 1562 | |
1563 | 1563 | /** |
1564 | | - * @return bool whether or not the page surpasses $wgDeleteRevisionsLimit revisions |
| 1564 | + * Check whether the number of revisions of this page surpasses $wgDeleteRevisionsLimit |
| 1565 | + * |
| 1566 | + * @deprecated in 1.19; use Title::isBigDeletion() instead. |
| 1567 | + * @return bool |
1565 | 1568 | */ |
1566 | 1569 | public function isBigDeletion() { |
1567 | | - global $wgDeleteRevisionsLimit; |
1568 | | - |
1569 | | - if ( $wgDeleteRevisionsLimit ) { |
1570 | | - $revCount = $this->estimateRevisionCount(); |
1571 | | - |
1572 | | - return $revCount > $wgDeleteRevisionsLimit; |
1573 | | - } |
1574 | | - |
1575 | | - return false; |
| 1570 | + wfDeprecated( __METHOD__, '1.19' ); |
| 1571 | + return $this->mTitle->isBigDeletion(); |
1576 | 1572 | } |
1577 | 1573 | |
1578 | 1574 | /** |
1579 | | - * @return int approximate revision count |
| 1575 | + * Get the approximate revision count of this page. |
| 1576 | + * |
| 1577 | + * @deprecated in 1.19; use Title::estimateRevisionCount() instead. |
| 1578 | + * @return int |
1580 | 1579 | */ |
1581 | 1580 | public function estimateRevisionCount() { |
1582 | | - $dbr = wfGetDB( DB_SLAVE ); |
1583 | | - return $dbr->estimateRowCount( 'revision', '*', |
1584 | | - array( 'rev_page' => $this->getId() ), __METHOD__ ); |
| 1581 | + wfDeprecated( __METHOD__, '1.19' ); |
| 1582 | + return $this->mTitle->estimateRevisionCount(); |
1585 | 1583 | } |
1586 | 1584 | |
1587 | 1585 | /** |
Index: trunk/phase3/includes/specials/SpecialMovepage.php |
— | — | @@ -360,13 +360,11 @@ |
361 | 361 | $nt = $this->newTitle; |
362 | 362 | |
363 | 363 | # Delete to make way if requested |
364 | | - if ( !count( $nt->getUserPermissionsErrors( 'delete', $user ) ) && $this->deleteAndMove ) { |
365 | | - $page = WikiPage::factory( $nt ); |
366 | | - |
367 | | - # Disallow deletions of big articles |
368 | | - $bigHistory = $page->isBigDeletion(); |
369 | | - if( $bigHistory && count( $nt->getUserPermissionsErrors( 'bigdelete', $user ) ) ) { |
370 | | - $this->showForm( array( 'delete-toobig', $this->getLanguage()->formatNum( $wgDeleteRevisionsLimit ) ) ); |
| 364 | + if ( $this->deleteAndMove ) { |
| 365 | + $permErrors = $nt->getUserPermissionsErrors( 'delete', $user ); |
| 366 | + if ( count( $permErrors ) ) { |
| 367 | + # Only show the first error |
| 368 | + $this->showForm( $permErrors[0] ); |
371 | 369 | return; |
372 | 370 | } |
373 | 371 | |
— | — | @@ -381,6 +379,7 @@ |
382 | 380 | } |
383 | 381 | |
384 | 382 | $error = ''; // passed by ref |
| 383 | + $page = WikiPage::factory( $nt ); |
385 | 384 | if ( !$page->doDeleteArticle( $reason, false, 0, true, $error, $user ) ) { |
386 | 385 | $this->showForm( array( 'cannotdelete', wfEscapeWikiText( $nt->getPrefixedText() ) ) ); |
387 | 386 | return; |