Index: trunk/phase3/includes/Article.php |
— | — | @@ -967,6 +967,13 @@ |
968 | 968 | $wgOut->addWikiMsg('anontalkpagetext'); |
969 | 969 | } |
970 | 970 | |
| 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 | + } |
971 | 978 | # If we have been passed an &rcid= parameter, we want to give the user a |
972 | 979 | # chance to mark this new article as patrolled. |
973 | 980 | if( !empty($rcid) && $this->mTitle->exists() && $this->mTitle->userCan('patrol') ) { |
Index: trunk/phase3/includes/Revision.php |
— | — | @@ -363,6 +363,7 @@ |
364 | 364 | } else { |
365 | 365 | throw new MWException( 'Revision constructor passed invalid row format.' ); |
366 | 366 | } |
| 367 | + $this->mUnpatrolled = NULL; |
367 | 368 | } |
368 | 369 | |
369 | 370 | /**#@+ |
— | — | @@ -536,6 +537,27 @@ |
537 | 538 | public function isMinor() { |
538 | 539 | return (bool)$this->mMinorEdit; |
539 | 540 | } |
| 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 | + } |
540 | 562 | |
541 | 563 | /** |
542 | 564 | * int $field one of DELETED_* bitfield constants |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -3034,6 +3034,28 @@ |
3035 | 3035 | } |
3036 | 3036 | |
3037 | 3037 | /** |
| 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 | + /** |
3038 | 3060 | * Check if this is a new page |
3039 | 3061 | * |
3040 | 3062 | * @return bool |