Hoo man has uploaded a new change for review.
https://gerrit.wikimedia.org/r/131264
Change subject: Don't estimate the revision count for bidelete
......................................................................
Don't estimate the revision count for bidelete
Don't try to estimate the revision count when trying
to find out whether we have a big deletion or not.
Often the estimated revision count is several thousands
of the real one, thus disallowing normal sysops to
delete pages, which they actually should be able
to delete.
The new query is heavier than the old one, but still
fast enough to be used over here (we also already use
it in InfoAction).
This change also introduces Title::getRevisionCount
Change-Id: Id0d02aa9960477a0cec8752ef714b6bc6b9ff2ac
---
M includes/Title.php
M includes/actions/InfoAction.php
2 files changed, 37 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/64/131264/1
diff --git a/includes/Title.php b/includes/Title.php
index 70d2baa..bec40fb 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -67,6 +67,7 @@
var $mLatestID = false; // /< ID of most recent revision
var $mContentModel = false; // /< ID of the page's content model,
i.e. one of the CONTENT_MODEL_XXX constants
private $mEstimateRevisions; // /< Estimated number of revisions;
null of not loaded
+ private $mRevisionCount; // /< Number of revisions;
null of not loaded
var $mRestrictions = array(); // /< Array of groups allowed to edit
this article
var $mOldRestrictions = false;
var $mCascadeRestriction; ///< Cascade restrictions on this
page to included templates and images?
@@ -3216,6 +3217,7 @@
$this->mLatestID = false;
$this->mContentModel = false;
$this->mEstimateRevisions = null;
+ $this->mRevisionCount = null;
$this->mPageLanguage = false;
}
@@ -4274,18 +4276,23 @@
return false;
}
- $revCount = $this->estimateRevisionCount();
+ $revCount = $this->getRevisionCount();
return $revCount > $wgDeleteRevisionsLimit;
}
/**
- * Get the approximate revision count of this page.
+ * Get the approximate revision count of this page.
*
* @return int
*/
public function estimateRevisionCount() {
if ( !$this->exists() ) {
return 0;
+ }
+
+ if ( $this->mRevisionCount !== null ) {
+ // If we have the real count around anyway, return it
+ return $this->mRevisionCount;
}
if ( $this->mEstimateRevisions === null ) {
@@ -4298,6 +4305,33 @@
}
/**
+ * Get the revision count of this page.
+ *
+ * Please note that this is a quite heavy action! Thus you should only
call this
+ * if you really need it and know what you're doing. For all other
purposes
+ * there's Title::estimateRevisionCount()
+ *
+ * @return int
+ */
+ public function getRevisionCount() {
+ if ( !$this->exists() ) {
+ return 0;
+ }
+
+ if ( $this->mRevisionCount === null ) {
+ $dbr = wfGetDB( DB_SLAVE );
+ $this->mRevisionCount = (int)$dbr->selectField(
+ 'revision',
+ 'COUNT(rev_page)',
+ array( 'rev_page' => $this->getArticleID() ),
+ __METHOD__
+ );
+ }
+
+ return $this->mRevisionCount;
+ }
+
+ /**
* Get the number of revisions between the given revision.
* Used for diffs and other things that really need it.
*
diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php
index 6b25460..14335f6 100644
--- a/includes/actions/InfoAction.php
+++ b/includes/actions/InfoAction.php
@@ -655,13 +655,7 @@
$result['watchers'] = $watchers;
// Total number of edits
- $edits = (int)$dbr->selectField(
- 'revision',
- 'COUNT(rev_page)',
- array( 'rev_page' => $id ),
- __METHOD__
- );
- $result['edits'] = $edits;
+ $result['edits'] = $title->getRevisionCount();
// Total number of distinct authors
$authors = (int)$dbr->selectField(
--
To view, visit https://gerrit.wikimedia.org/r/131264
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id0d02aa9960477a0cec8752ef714b6bc6b9ff2ac
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits