r45778 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45777‎ | r45778 | r45779 >
Date:17:53, 15 January 2009
Author:aaron
Status:reverted (Comments)
Tags:
Comment:
(Bug 15936) New page's patrol button should always be visible
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Revision.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -967,6 +967,13 @@
968968 $wgOut->addWikiMsg('anontalkpagetext');
969969 }
970970
 971+ # Only diffs and new page links from RC give rcid params, so if
 972+ # we are just viewing the page normally with no rcid, try to find it.
 973+ # This is more convenient for users.
 974+ if( empty($rcid) && $this->mTitle->userCan('patrol') ) {
 975+ $firstRev = $this->mTitle->getFirstRevision();
 976+ $rcid = $firstRev->isUnpatrolled();
 977+ }
971978 # If we have been passed an &rcid= parameter, we want to give the user a
972979 # chance to mark this new article as patrolled.
973980 if( !empty($rcid) && $this->mTitle->exists() && $this->mTitle->userCan('patrol') ) {
Index: trunk/phase3/includes/Revision.php
@@ -363,6 +363,7 @@
364364 } else {
365365 throw new MWException( 'Revision constructor passed invalid row format.' );
366366 }
 367+ $this->mUnpatrolled = NULL;
367368 }
368369
369370 /**#@+
@@ -536,6 +537,27 @@
537538 public function isMinor() {
538539 return (bool)$this->mMinorEdit;
539540 }
 541+
 542+ /**
 543+ * @return int rcid of the unpatrolled row, zero if there isn't one
 544+ */
 545+ public function isUnpatrolled() {
 546+ if( $this->mUnpatrolled !== NULL ) {
 547+ return $this->mUnpatrolled;
 548+ }
 549+ $dbr = wfGetDB( DB_SLAVE );
 550+ $this->mUnpatrolled = $dbr->selectField( 'recentchanges',
 551+ 'rc_id',
 552+ array( // Add redundant user,timestamp condition so we can use the existing index
 553+ 'rc_user_text' => $this->getRawUserText(),
 554+ 'rc_timestamp' => $dbr->timestamp( $this->getTimestamp() ),
 555+ 'rc_this_oldid' => $this->getId(),
 556+ 'rc_patrolled' => 0
 557+ ),
 558+ __METHOD__
 559+ );
 560+ return (int)$this->mUnpatrolled;
 561+ }
540562
541563 /**
542564 * int $field one of DELETED_* bitfield constants
Index: trunk/phase3/includes/Title.php
@@ -3034,6 +3034,28 @@
30353035 }
30363036
30373037 /**
 3038+ * Get the first revision of the page
 3039+ *
 3040+ * @param $flags \type{\int} GAID_FOR_UPDATE
 3041+ * @return Revision (or NULL if page doesn't exist)
 3042+ */
 3043+ public function getFirstRevision( $flags=0 ) {
 3044+ $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
 3045+ $pageId = $this->getArticleId($flags);
 3046+ if( !$pageId ) return NULL;
 3047+ $row = $db->selectRow( 'revision', '*',
 3048+ array( 'rev_page' => $pageId ),
 3049+ __METHOD__,
 3050+ array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 )
 3051+ );
 3052+ if( !$row ) {
 3053+ return NULL;
 3054+ } else {
 3055+ return new Revision( $row );
 3056+ }
 3057+ }
 3058+
 3059+ /**
30383060 * Check if this is a new page
30393061 *
30403062 * @return bool

Follow-up revisions

RevisionCommit summaryAuthorDate
r45793Tweak r45778, check exists()aaron13:23, 16 January 2009
r46542Partial revert of r45778 and friends "(bug 15936) New page's patrol button s...brion18:00, 29 January 2009

Comments

#Comment by Nikerabbit (talk | contribs)   11:18, 16 January 2009

This breaks page view of non-existent pages like http://translatewiki.net/wiki/Foobar when logged in.

#Comment by Aaron Schulz (talk | contribs)   13:24, 16 January 2009

Fixed in r45793

#Comment by Nikerabbit (talk | contribs)   16:37, 16 January 2009

Works, thanks.

#Comment by Brion VIBBER (talk | contribs)   18:01, 29 January 2009

Partially reverted in r46542 -- this has caused performance regressions.

Status & tagging log