r49895 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49894‎ | r49895 | r49896 >
Date:10:51, 26 April 2009
Author:aaron
Status:ok
Tags:
Comment:
* Split up updateArticleOn() and fix some cases where tracking updates were not done as needed
* Streamlined updateArticleOn() by removing count cache update
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/maintenance/updateLinks.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/maintenance/updateLinks.inc
@@ -120,7 +120,7 @@
121121 $frev = FlaggedRevision::newFromStable( $title, FR_FOR_UPDATE );
122122 # Update fp_stable, fp_quality, and fp_reviewed
123123 if( $frev ) {
124 - FlaggedRevs::updateArticleOn( $article, $frev->getRevision(), $row->page_latest );
 124+ FlaggedRevs::updateStableVersion( $article, $frev->getRevision(), $row->page_latest );
125125 # Somethings broke? Delete the row...
126126 } else {
127127 $db->delete( 'flaggedpages', array( 'fp_page_id' => $row->page_id ), __FUNCTION__ );
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -783,9 +783,9 @@
784784 * @param mixed $latest, the latest rev ID (optional)
785785 * Updates the flaggedpages fields
786786 */
787 - public static function updateArticleOn( $article, $rev, $latest=NULL ) {
788 - if( !$article->getId() ) return true; // no bogus entries
789 - $revId = $rev->getId();
 787+ public static function updateStableVersion( $article, $rev, $latest = NULL ) {
 788+ if( !$article->getId() )
 789+ return true; // no bogus entries
790790 # Get the latest revision ID
791791 $lastID = $latest ? $latest : $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE);
792792 # Get the highest quality revision (not necessarily this one)
@@ -801,6 +801,7 @@
802802 array( 'ORDER BY' => 'fr_quality DESC', 'LIMIT' => 1 )
803803 );
804804 # Get the timestamp of the edit after the stable version (if any)
 805+ $revId = $rev->getId();
805806 if( $lastID != $revId ) {
806807 # Get the latest revision ID
807808 $timestamp = $rev->getTimestamp();
@@ -825,19 +826,34 @@
826827 __METHOD__
827828 );
828829 # Alter pending edit tracking table
 830+ self::updatePendingList( $article, $latest );
 831+ return true;
 832+ }
 833+
 834+ /**
 835+ * @param Article $article
 836+ * @param mixed $latest, the latest rev ID (optional)
 837+ * Updates the flaggedpage_pending table
 838+ */
 839+ public static function updatePendingList( $article, $latest = NULL ) {
829840 $data = array();
830841 $level = self::pristineVersions() ? 2 : 1;
831842 if( !self::qualityVersions() ) $level--;
 843+ # Get the latest revision ID
 844+ $lastID = $latest ? $latest : $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE);
 845+ $pageId = $article->getId();
832846 # Update pending times for each level
 847+ $dbw = wfGetDB( DB_MASTER );
833848 while( $level >= 0 ) {
834849 # Get the latest revision of this level...
835850 $row = $dbw->selectRow( array('flaggedrevs','revision'),
836851 array( 'fr_rev_id', 'rev_timestamp' ),
837 - array( 'fr_page_id' => $article->getId(),
 852+ array( 'fr_page_id' => $pageId,
838853 'fr_quality' => $level,
839854 'rev_id = fr_rev_id',
840855 'rev_page = fr_page_id',
841 - 'rev_deleted & '.Revision::DELETED_TEXT => 0 ),
 856+ 'rev_deleted & '.Revision::DELETED_TEXT => 0
 857+ ),
842858 __METHOD__,
843859 array( 'ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 )
844860 );
@@ -848,13 +864,13 @@
849865 if( $lastID != $id ) {
850866 $nextTimestamp = $dbw->selectField( 'revision',
851867 'rev_timestamp',
852 - array( 'rev_page' => $article->getId(),
 868+ array( 'rev_page' => $pageId,
853869 "rev_timestamp > ".$dbw->addQuotes( $row->rev_timestamp ) ),
854870 __METHOD__,
855871 array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 )
856872 );
857873 $data[] = array(
858 - 'fpp_page_id' => $article->getId(),
 874+ 'fpp_page_id' => $pageId,
859875 'fpp_quality' => $level,
860876 'fpp_rev_id' => $id,
861877 'fpp_pending_since' => $nextTimestamp
@@ -864,11 +880,8 @@
865881 $level--;
866882 }
867883 # Clear any old junk, and insert new rows
868 - $dbw->delete( 'flaggedpage_pending', array('fpp_page_id' => $article->getId()), __METHOD__ );
 884+ $dbw->delete( 'flaggedpage_pending', array('fpp_page_id' => $pageId), __METHOD__ );
869885 $dbw->insert( 'flaggedpage_pending', $data, __METHOD__ );
870 - # Updates the count cache
871 - $count = self::getRevCountSince( $article, $revId, true );
872 -
873886 return true;
874887 }
875888
@@ -1428,12 +1441,15 @@
14291442 # Update stable cache
14301443 self::updatePageCache( $article, $poutput );
14311444 # Update page fields
1432 - self::updateArticleOn( $article, $rev, $rev->getId() );
 1445+ self::updateStableVersion( $article, $rev, $rev->getId() );
14331446 # We can set the sync cache key already.
14341447 global $wgParserCacheExpireTime;
14351448 $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $article->getId() );
14361449 $data = FlaggedRevs::makeMemcObj( "true" );
14371450 $wgMemc->set( $key, $data, $wgParserCacheExpireTime );
 1451+ } else {
 1452+ # Update tracking table
 1453+ self::updatePendingList( $article, $rev->getId() );
14381454 }
14391455 wfProfileOut( __METHOD__ );
14401456 return true;
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -165,8 +165,9 @@
166166 $u->fr_stableRev : FlaggedRevision::newFromStable( $linksUpdate->mTitle, FR_MASTER );
167167 # Empty flagged revs data for this page if there is no stable version
168168 if( !$sv ) {
169 - $dbw->delete( 'flaggedpages', array( 'fp_page_id' => $pageId ), __METHOD__ );
170 - $dbw->delete( 'flaggedrevs_tracking', array( 'ftr_from' => $pageId ), __METHOD__ );
 169+ $dbw->delete( 'flaggedpages', array('fp_page_id' => $pageId), __METHOD__ );
 170+ $dbw->delete( 'flaggedrevs_tracking', array('ftr_from' => $pageId), __METHOD__ );
 171+ $dbw->delete( 'flaggedpage_pending', array('fpp_page_id' => $pageId), __METHOD__ );
171172 return true;
172173 }
173174 # Try the process cache...
@@ -183,7 +184,7 @@
184185 }
185186 }
186187 # Update page fields
187 - FlaggedRevs::updateArticleOn( $article, $sv->getRevision() );
 188+ FlaggedRevs::updateStableVersion( $article, $sv->getRevision() );
188189 # We only care about links that are only in the stable version
189190 $links = array();
190191 foreach( $parserOut->getLinks() as $ns => $titles ) {

Status & tagging log