Index: trunk/extensions/FlaggedRevs/maintenance/updateLinks.inc |
— | — | @@ -120,7 +120,7 @@ |
121 | 121 | $frev = FlaggedRevision::newFromStable( $title, FR_FOR_UPDATE ); |
122 | 122 | # Update fp_stable, fp_quality, and fp_reviewed |
123 | 123 | if( $frev ) { |
124 | | - FlaggedRevs::updateArticleOn( $article, $frev->getRevision(), $row->page_latest ); |
| 124 | + FlaggedRevs::updateStableVersion( $article, $frev->getRevision(), $row->page_latest ); |
125 | 125 | # Somethings broke? Delete the row... |
126 | 126 | } else { |
127 | 127 | $db->delete( 'flaggedpages', array( 'fp_page_id' => $row->page_id ), __FUNCTION__ ); |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -783,9 +783,9 @@ |
784 | 784 | * @param mixed $latest, the latest rev ID (optional) |
785 | 785 | * Updates the flaggedpages fields |
786 | 786 | */ |
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 |
790 | 790 | # Get the latest revision ID |
791 | 791 | $lastID = $latest ? $latest : $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE); |
792 | 792 | # Get the highest quality revision (not necessarily this one) |
— | — | @@ -801,6 +801,7 @@ |
802 | 802 | array( 'ORDER BY' => 'fr_quality DESC', 'LIMIT' => 1 ) |
803 | 803 | ); |
804 | 804 | # Get the timestamp of the edit after the stable version (if any) |
| 805 | + $revId = $rev->getId(); |
805 | 806 | if( $lastID != $revId ) { |
806 | 807 | # Get the latest revision ID |
807 | 808 | $timestamp = $rev->getTimestamp(); |
— | — | @@ -825,19 +826,34 @@ |
826 | 827 | __METHOD__ |
827 | 828 | ); |
828 | 829 | # 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 ) { |
829 | 840 | $data = array(); |
830 | 841 | $level = self::pristineVersions() ? 2 : 1; |
831 | 842 | if( !self::qualityVersions() ) $level--; |
| 843 | + # Get the latest revision ID |
| 844 | + $lastID = $latest ? $latest : $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE); |
| 845 | + $pageId = $article->getId(); |
832 | 846 | # Update pending times for each level |
| 847 | + $dbw = wfGetDB( DB_MASTER ); |
833 | 848 | while( $level >= 0 ) { |
834 | 849 | # Get the latest revision of this level... |
835 | 850 | $row = $dbw->selectRow( array('flaggedrevs','revision'), |
836 | 851 | array( 'fr_rev_id', 'rev_timestamp' ), |
837 | | - array( 'fr_page_id' => $article->getId(), |
| 852 | + array( 'fr_page_id' => $pageId, |
838 | 853 | 'fr_quality' => $level, |
839 | 854 | 'rev_id = fr_rev_id', |
840 | 855 | 'rev_page = fr_page_id', |
841 | | - 'rev_deleted & '.Revision::DELETED_TEXT => 0 ), |
| 856 | + 'rev_deleted & '.Revision::DELETED_TEXT => 0 |
| 857 | + ), |
842 | 858 | __METHOD__, |
843 | 859 | array( 'ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) |
844 | 860 | ); |
— | — | @@ -848,13 +864,13 @@ |
849 | 865 | if( $lastID != $id ) { |
850 | 866 | $nextTimestamp = $dbw->selectField( 'revision', |
851 | 867 | 'rev_timestamp', |
852 | | - array( 'rev_page' => $article->getId(), |
| 868 | + array( 'rev_page' => $pageId, |
853 | 869 | "rev_timestamp > ".$dbw->addQuotes( $row->rev_timestamp ) ), |
854 | 870 | __METHOD__, |
855 | 871 | array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 ) |
856 | 872 | ); |
857 | 873 | $data[] = array( |
858 | | - 'fpp_page_id' => $article->getId(), |
| 874 | + 'fpp_page_id' => $pageId, |
859 | 875 | 'fpp_quality' => $level, |
860 | 876 | 'fpp_rev_id' => $id, |
861 | 877 | 'fpp_pending_since' => $nextTimestamp |
— | — | @@ -864,11 +880,8 @@ |
865 | 881 | $level--; |
866 | 882 | } |
867 | 883 | # 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__ ); |
869 | 885 | $dbw->insert( 'flaggedpage_pending', $data, __METHOD__ ); |
870 | | - # Updates the count cache |
871 | | - $count = self::getRevCountSince( $article, $revId, true ); |
872 | | - |
873 | 886 | return true; |
874 | 887 | } |
875 | 888 | |
— | — | @@ -1428,12 +1441,15 @@ |
1429 | 1442 | # Update stable cache |
1430 | 1443 | self::updatePageCache( $article, $poutput ); |
1431 | 1444 | # Update page fields |
1432 | | - self::updateArticleOn( $article, $rev, $rev->getId() ); |
| 1445 | + self::updateStableVersion( $article, $rev, $rev->getId() ); |
1433 | 1446 | # We can set the sync cache key already. |
1434 | 1447 | global $wgParserCacheExpireTime; |
1435 | 1448 | $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $article->getId() ); |
1436 | 1449 | $data = FlaggedRevs::makeMemcObj( "true" ); |
1437 | 1450 | $wgMemc->set( $key, $data, $wgParserCacheExpireTime ); |
| 1451 | + } else { |
| 1452 | + # Update tracking table |
| 1453 | + self::updatePendingList( $article, $rev->getId() ); |
1438 | 1454 | } |
1439 | 1455 | wfProfileOut( __METHOD__ ); |
1440 | 1456 | return true; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -165,8 +165,9 @@ |
166 | 166 | $u->fr_stableRev : FlaggedRevision::newFromStable( $linksUpdate->mTitle, FR_MASTER ); |
167 | 167 | # Empty flagged revs data for this page if there is no stable version |
168 | 168 | 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__ ); |
171 | 172 | return true; |
172 | 173 | } |
173 | 174 | # Try the process cache... |
— | — | @@ -183,7 +184,7 @@ |
184 | 185 | } |
185 | 186 | } |
186 | 187 | # Update page fields |
187 | | - FlaggedRevs::updateArticleOn( $article, $sv->getRevision() ); |
| 188 | + FlaggedRevs::updateStableVersion( $article, $sv->getRevision() ); |
188 | 189 | # We only care about links that are only in the stable version |
189 | 190 | $links = array(); |
190 | 191 | foreach( $parserOut->getLinks() as $ns => $titles ) { |