r79932 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79931‎ | r79932 | r79933 >
Date:08:47, 10 January 2011
Author:ialex
Status:deferred
Tags:
Comment:
Much easier to call Title::getLatestRevID()
Modified paths:
  • /trunk/extensions/WikiTrust/includes/WikiTrustBase.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiTrust/includes/WikiTrustBase.php
@@ -735,33 +735,13 @@
736736
737737 /* Utility function which returns the revid of the revision which is
738738 * currently being displayed.
739 - * It tries to do this using the global wgArticle object, and if this fails
740 - * queries the DB directly.
741739 *
742740 * This is a replacement for getRevFTitle() and eliminates 1 db call.
743741 */
744742 static function util_getRevFArticle()
745743 {
746 - // If no revid, assume it is the most recent one.
747 - // Try using the article object, and only if this fails use the Title.
748 - global $wgArticle;
749 - $rev_id = 0;
750 - if (method_exists($wgArticle, "getLatest"))
751 - $rev_id = $wgArticle->getLatest();
752 - else { // Otherwise, ask the db for the latest revid for the given pageid.
753 - global $wgTitle;
754 - $rev_id = 0;
755 - $page_id = $wgTitle->getArticleID();
756 - $dbr = wfGetDB( DB_SLAVE );
757 - $res = $dbr->select('page', array('page_latest'),
758 - array('page_id' => $page_id), array());
759 - if ($res && $dbr->numRows($res) > 0) {
760 - $row = $dbr->fetchRow($res);
761 - $rev_id = $row['page_latest'];
762 - }
763 - $dbr->freeResult( $res );
764 - }
765 - return $rev_id;
 744+ global $wgTitle;
 745+ return $wgTitle->getLatestRevID();
766746 }
767747
768748 // Returns the current revid from the $out object.

Status & tagging log