Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -945,13 +945,9 @@ |
946 | 946 | # Try the sync value cache... |
947 | 947 | $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $article->getId() ); |
948 | 948 | $value = FlaggedRevs::getMemcValue( $wgMemc->get($key), $article ); |
949 | | - if( $value === "true" ) { |
950 | | - $synced = true; |
951 | | - } else { |
952 | | - $synced = false; // default as false to trigger query |
953 | | - } |
| 949 | + $synced = ($value === "true") ? true : false; // default as false to trigger query |
954 | 950 | $frev = $this->getStableRev(); |
955 | | - if( $frev && $frev->getRevId() == $oldRev->getID() && !$synced ) { |
| 951 | + if( $frev && $frev->getRevId() == $oldRev->getID() ) { |
956 | 952 | global $wgParserCacheExpireTime, $wgUseStableTemplates, $wgUseStableImages; |
957 | 953 | |
958 | 954 | $changeList = array(); |
— | — | @@ -960,6 +956,9 @@ |
961 | 957 | # Try the cache. Uses format <page ID>-<UNIX timestamp>. |
962 | 958 | $key = wfMemcKey( 'stableDiffs', 'templates', (bool)$wgUseStableTemplates, $article->getId() ); |
963 | 959 | $tmpChanges = FlaggedRevs::getMemcValue( $wgMemc->get($key), $article ); |
| 960 | + if( empty($tmpChanges) && !$synced ) { |
| 961 | + $tmpChanges = false; // don't use cache |
| 962 | + } |
964 | 963 | |
965 | 964 | # Make a list of each changed template... |
966 | 965 | if( $tmpChanges === false ) { |
— | — | @@ -967,14 +966,10 @@ |
968 | 967 | // Get templates where the current and stable are not the same revision |
969 | 968 | if( $wgUseStableTemplates ) { |
970 | 969 | $ret = $dbr->select( array('flaggedtemplates','page','flaggedpages'), |
971 | | - array( 'ft_namespace', 'ft_title', 'fp_stable','ft_tmp_rev_id' ), |
| 970 | + array( 'ft_namespace', 'ft_title', 'fp_stable','ft_tmp_rev_id', 'page_latest' ), |
972 | 971 | array( 'ft_rev_id' => $frev->getRevId(), |
973 | 972 | 'page_namespace = ft_namespace', |
974 | | - 'page_title = ft_title', |
975 | | - // If the page has a stable version, is it current? |
976 | | - // If not, is the specified one at review time current? |
977 | | - '(fp_stable IS NOT NULL AND fp_stable != page_latest) OR |
978 | | - (fp_stable IS NULL AND ft_tmp_rev_id != page_latest)' ), |
| 973 | + 'page_title = ft_title' ), |
979 | 974 | __METHOD__, |
980 | 975 | array(), /* OPTIONS */ |
981 | 976 | array( 'flaggedpages' => array('LEFT JOIN','fp_page_id = page_id') ) |
— | — | @@ -982,7 +977,7 @@ |
983 | 978 | // Get templates that are newer than the ones of the stable version of this page |
984 | 979 | } else { |
985 | 980 | $ret = $dbr->select( array('flaggedtemplates','page'), |
986 | | - array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id' ), |
| 981 | + array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id', 'page_latest' ), |
987 | 982 | array( 'ft_rev_id' => $frev->getRevId(), |
988 | 983 | 'page_namespace = ft_namespace', |
989 | 984 | 'page_title = ft_title', |
— | — | @@ -992,9 +987,15 @@ |
993 | 988 | $tmpChanges = array(); |
994 | 989 | while( $row = $dbr->fetchObject( $ret ) ) { |
995 | 990 | $title = Title::makeTitle( $row->ft_namespace, $row->ft_title ); |
996 | | - $revID = isset($row->fp_stable) ? $row->fp_stable : $row->ft_tmp_rev_id; |
997 | | - $tmpChanges[] = $skin->makeKnownLinkObj( $title, $title->getPrefixedText(), |
998 | | - "diff=cur&oldid={$revID}" ); |
| 991 | + $revIdDraft = $row->page_latest; |
| 992 | + // stable time -> time when reviewed (unless the other is newer) |
| 993 | + $revIdStable = isset($row->fp_stable) && $row->fp_stable >= $row->ft_tmp_rev_id ? |
| 994 | + $row->fp_stable : $row->ft_tmp_rev_id; |
| 995 | + // compare to current |
| 996 | + if( $revIdDraft > $revIdStable ) { |
| 997 | + $tmpChanges[] = $skin->makeKnownLinkObj( $title, $title->getPrefixedText(), |
| 998 | + "diff=cur&oldid={$revID}" ); |
| 999 | + } |
999 | 1000 | } |
1000 | 1001 | $wgMemc->set( $key, FlaggedRevs::makeMemcObj($tmpChanges), $wgParserCacheExpireTime ); |
1001 | 1002 | } |
— | — | @@ -1005,6 +1006,9 @@ |
1006 | 1007 | # Try the cache. Uses format <page ID>-<UNIX timestamp>. |
1007 | 1008 | $key = wfMemcKey( 'stableDiffs', 'images', (bool)$wgUseStableImages, $article->getId() ); |
1008 | 1009 | $imgChanges = FlaggedRevs::getMemcValue( $wgMemc->get($key), $article ); |
| 1010 | + if( empty($imgChanges) && !$synced ) { |
| 1011 | + $imgChanges = false; // don't use cache |
| 1012 | + } |
1009 | 1013 | |
1010 | 1014 | // Get list of each changed image... |
1011 | 1015 | if( $imgChanges === false ) { |
— | — | @@ -1031,11 +1035,11 @@ |
1032 | 1036 | } |
1033 | 1037 | $imgChanges = array(); |
1034 | 1038 | while( $row = $dbr->fetchObject( $ret ) ) { |
| 1039 | + $title = Title::makeTitle( NS_IMAGE, $row->fi_name ); |
1035 | 1040 | // stable time -> time when reviewed (unless the other is newer) |
1036 | 1041 | $timestamp = isset($row->fr_img_timestamp) && $row->fr_img_timestamp >= $row->fi_img_timestamp ? |
1037 | 1042 | $row->fr_img_timestamp : $row->fi_img_timestamp; |
1038 | 1043 | // compare to current |
1039 | | - $title = Title::makeTitle( NS_IMAGE, $row->fi_name ); |
1040 | 1044 | $file = wfFindFile( $title ); |
1041 | 1045 | if( $file && $file->getTimestamp() > $timestamp ) |
1042 | 1046 | $imgChanges[] = $skin->makeKnownLinkObj( $title, $title->getPrefixedText() ); |