Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.hooks.php |
— | — | @@ -323,12 +323,9 @@ |
324 | 324 | } elseif ( $action === 'patrol' || $action === 'autopatrol' ) { |
325 | 325 | $flaggedArticle = FlaggableWikiPage::getTitleInstance( $title ); |
326 | 326 | # For a page to be patrollable it must not be reviewable. |
327 | | - # Note: normally, edits to non-reviewable, non-patrollable, pages are |
328 | | - # silently marked patrolled automatically. With $wgUseNPPatrol on, the |
329 | | - # first edit to those pages is left as being unpatrolled. |
330 | 327 | if ( $flaggedArticle->isReviewable() ) { |
331 | 328 | $result = false; |
332 | | - return false; |
| 329 | + return false; // patrol by "accepting" |
333 | 330 | } |
334 | 331 | # Enforce autoreview/review restrictions |
335 | 332 | } elseif ( $action === 'autoreview' || $action === 'review' ) { |
— | — | @@ -617,7 +614,7 @@ |
618 | 615 | $rc->mAttribs['rc_cur_id'], $revId, FR_MASTER ); |
619 | 616 | // Reviewed => patrolled |
620 | 617 | if ( $quality !== false && $quality >= FR_CHECKED ) { |
621 | | - RevisionReviewForm::updateRecentChanges( $rc->getTitle(), $revId ); |
| 618 | + RevisionReviewForm::updateRecentChanges( $rc, 'patrol', $fa->getStableRev() ); |
622 | 619 | $rc->mAttribs['rc_patrolled'] = 1; // make sure irc/email notifs know status |
623 | 620 | } |
624 | 621 | return true; |
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.class.php |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | self::$restrictionLevels = array_unique( $wgFlaggedRevsRestrictionLevels ); |
111 | 111 | self::$restrictionLevels = array_filter( self::$restrictionLevels, 'strlen' ); |
112 | 112 | # Make sure no talk namespaces are in review namespace |
113 | | - global $wgFlaggedRevsNamespaces, $wgFlaggedRevsPatrolNamespaces; |
| 113 | + global $wgFlaggedRevsNamespaces; |
114 | 114 | foreach ( $wgFlaggedRevsNamespaces as $ns ) { |
115 | 115 | if ( MWNamespace::isTalk( $ns ) ) { |
116 | 116 | die( 'FlaggedRevs given talk namespace in $wgFlaggedRevsNamespaces!' ); |
Index: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php |
— | — | @@ -395,10 +395,10 @@ |
396 | 396 | $oldFrev->delete(); |
397 | 397 | } |
398 | 398 | # Insert the new review entry... |
399 | | - $flaggedRevision->insert(); |
400 | | - # Update recent changes... |
401 | | - $rcId = $rev->isUnpatrolled(); // int |
402 | | - self::updateRecentChanges( $this->page, $rev->getId(), $rcId, true ); |
| 399 | + if ( !$flaggedRevision->insert() ) { |
| 400 | + throw new MWException( |
| 401 | + "Flagged revision with ID {$rev->getId()} exists with unexpected fr_page_id" ); |
| 402 | + } |
403 | 403 | |
404 | 404 | # Update the article review log... |
405 | 405 | $oldSvId = $oldSv ? $oldSv->getRevId() : 0; |
— | — | @@ -406,7 +406,9 @@ |
407 | 407 | $this->comment, $this->oldid, $oldSvId, true ); |
408 | 408 | |
409 | 409 | # Get the new stable version as of now |
410 | | - $sv = FlaggedRevision::determineStable( $this->page, FR_MASTER/*consistent*/ ); |
| 410 | + $sv = FlaggedRevision::determineStable( $this->page, FR_MASTER /*consistent*/ ); |
| 411 | + # Update recent changes... |
| 412 | + self::updateRecentChanges( $rev, 'patrol', $sv ); |
411 | 413 | # Update page and tracking tables and clear cache |
412 | 414 | $changed = FlaggedRevs::stableVersionUpdates( $this->page, $sv, $oldSv ); |
413 | 415 | if ( $changed ) { |
— | — | @@ -432,8 +434,6 @@ |
433 | 435 | |
434 | 436 | # Delete from flaggedrevs table |
435 | 437 | $frev->delete(); |
436 | | - # Update recent changes |
437 | | - self::updateRecentChanges( $this->page, $frev->getRevId(), false, false ); |
438 | 438 | |
439 | 439 | # Update the article review log |
440 | 440 | $oldSvId = $oldSv ? $oldSv->getRevId() : 0; |
— | — | @@ -442,6 +442,8 @@ |
443 | 443 | |
444 | 444 | # Get the new stable version as of now |
445 | 445 | $sv = FlaggedRevision::determineStable( $this->page, FR_MASTER /*consistent*/ ); |
| 446 | + # Update recent changes |
| 447 | + self::updateRecentChanges( $frev->getRevision(), 'unpatrol', $sv ); |
446 | 448 | # Update page and tracking tables and clear cache |
447 | 449 | $changed = FlaggedRevs::stableVersionUpdates( $this->page, $sv, $oldSv ); |
448 | 450 | if ( $changed ) { |
— | — | @@ -470,32 +472,55 @@ |
471 | 473 | return $p; |
472 | 474 | } |
473 | 475 | |
474 | | - public static function updateRecentChanges( |
475 | | - Title $title, $revId, $rcId = false, $patrol = true |
476 | | - ) { |
477 | | - wfProfileIn( __METHOD__ ); |
478 | | - $revId = intval( $revId ); |
| 476 | + /** |
| 477 | + * Update rc_patrolled fields in recent changes after (un)accepting a rev. |
| 478 | + * This maintains the patrolled <=> reviewed relationship for reviewable namespaces. |
| 479 | + * @param $rev Revision|RecentChange |
| 480 | + * @param $patrol string "patrol" or "unpatrol" |
| 481 | + * @param $srev FlaggedRevsion|null The new stable version |
| 482 | + * @return void |
| 483 | + */ |
| 484 | + public static function updateRecentChanges( $rev, $patrol, $srev ) { |
| 485 | + global $wgUseRCPatrol; |
| 486 | + |
| 487 | + if ( $rev instanceof RecentChange ) { |
| 488 | + $pageId = $rc->mAttribs['rc_cur_id']; |
| 489 | + } else { |
| 490 | + $pageId = $rev->getPage(); |
| 491 | + } |
| 492 | + $sTimestamp = $srev ? $srev->getRevTimestamp() : null; |
| 493 | + |
479 | 494 | $dbw = wfGetDB( DB_MASTER ); |
480 | | - # Olders edits be marked as patrolled now... |
481 | | - $dbw->update( 'recentchanges', |
482 | | - array( 'rc_patrolled' => $patrol ? 1 : 0 ), |
483 | | - array( 'rc_cur_id' => $title->getArticleId(), |
484 | | - $patrol ? "rc_this_oldid <= $revId" : "rc_this_oldid = $revId" ), |
485 | | - __METHOD__, |
486 | | - // Performance |
487 | | - array( 'USE INDEX' => 'rc_cur_id', 'LIMIT' => 50 ) |
488 | | - ); |
489 | | - # New page patrol may be enabled. If so, the rc_id may be the first |
490 | | - # edit and not this one. If it is different, mark it too. |
491 | | - if ( $rcId && $rcId != $revId ) { |
| 495 | + $limit = 100; // sanity limit to avoid slave lag (most useful when FR is first enabled) |
| 496 | + $conds = array( 'rc_cur_id' => $pageId ); |
| 497 | + if ( !$wgUseRCPatrol ) { |
| 498 | + # No sense in updating all the rows, only the new page one is used. |
| 499 | + # If $wgUseNPPatrol is off, then not even those are used. |
| 500 | + $conds['rc_type'] = RC_NEW; // reduce rows to UPDATE |
| 501 | + } |
| 502 | + # If we accepted this rev, then mark prior revs as patrolled... |
| 503 | + if ( $patrol === 'patrol' ) { |
| 504 | + if ( $sTimestamp ) { // sanity check; should always be set |
| 505 | + $conds[] = 'rc_timestamp <= ' . $dbw->addQuotes( $dbw->timestamp( $sTimestamp ) ); |
| 506 | + $dbw->update( 'recentchanges', |
| 507 | + array( 'rc_patrolled' => 1 ), |
| 508 | + $conds, |
| 509 | + __METHOD__, |
| 510 | + array( 'USE INDEX' => 'rc_cur_id', 'LIMIT' => $limit ) // performance |
| 511 | + ); |
| 512 | + } |
| 513 | + # If we un-accepted this rev, then mark now-pending revs as unpatrolled... |
| 514 | + } elseif ( $patrol === 'unpatrol' ) { |
| 515 | + if ( $sTimestamp ) { |
| 516 | + $conds[] = 'rc_timestamp > ' . $dbw->addQuotes( $dbw->timestamp( $sTimestamp ) ); |
| 517 | + } |
492 | 518 | $dbw->update( 'recentchanges', |
493 | | - array( 'rc_patrolled' => 1 ), |
494 | | - array( 'rc_id' => $rcId, |
495 | | - 'rc_type' => RC_NEW ), |
496 | | - __METHOD__ |
| 519 | + array( 'rc_patrolled' => 0 ), |
| 520 | + $conds, |
| 521 | + __METHOD__, |
| 522 | + array( 'USE INDEX' => 'rc_cur_id', 'LIMIT' => $limit ) // performance |
497 | 523 | ); |
498 | 524 | } |
499 | | - wfProfileOut( __METHOD__ ); |
500 | 525 | } |
501 | 526 | |
502 | 527 | /** |
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.setup.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | public static function defineHookHandlers( &$hooks ) { |
15 | 15 | global $wgFlaggedRevsProtection; |
16 | 16 | |
17 | | - # Override current revision, add patrol links, set cache... |
| 17 | + # Override current revision, set cache... |
18 | 18 | $hooks['ArticleViewHeader'][] = 'FlaggedRevsUIHooks::onArticleViewHeader'; |
19 | 19 | $hooks['ImagePageFindFile'][] = 'FlaggedRevsUIHooks::onImagePageFindFile'; |
20 | 20 | # Override redirect behavior... |