r86451 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86450‎ | r86451 | r86452 >
Date:02:38, 20 April 2011
Author:mah
Status:resolved
Tags:
Comment:
* Move FlaggedRevs integration for GNSM to a hook that FlaggedRevs can use
* Rename GNSM::doQuery() to GNSM::getCategories() to avoid confusion with DB::doQuery()
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php
@@ -83,7 +83,7 @@
8484 echo $cached;
8585 echo "<!-- From cache: $cacheKey -->";
8686 } else {
87 - $res = $this->doQuery( $params, $categories, $notCategories );
 87+ $res = $this->getCategories( $params, $categories, $notCategories );
8888 ob_start();
8989 $this->makeFeed( $feed, $res );
9090 $output = ob_get_contents();
@@ -141,12 +141,12 @@
142142 }
143143 return $cached[1];
144144 }
 145+
145146 /**
146147 * Actually output a feed.
147148 * @param ChannelFeed $feed Feed object.
148149 * @param $res Result of sql query
149150 */
150 -
151151 private function makeFeed( $feed, $res ) {
152152 global $wgGNSMcommentNamespace;
153153 $feed->outHeader();
@@ -257,7 +257,7 @@
258258 * @param Array $param All the parameters except cats/notcats
259259 * @return Result of query.
260260 */
261 - public function doQuery( $params, $categories, $notCategories ) {
 261+ public function getCategories( $params, $categories, $notCategories ) {
262262
263263 $dbr = wfGetDB( DB_SLAVE );
264264
@@ -272,33 +272,8 @@
273273 $conditions['page_namespace'] = $params['namespace'];
274274 }
275275
276 - // If flagged revisions is in use, check which options selected.
277 - // FIXME: double check the default options; what should it default to?
278 - if ( function_exists( 'efLoadFlaggedRevs' ) ) {
279 - $filterSet = array( self::OPT_ONLY, self::OPT_EXCLUDE );
280 - # Either involves the same JOIN here...
281 - if ( in_array( $params['stable'], $filterSet ) || in_array( $params['quality'], $filterSet ) ) {
282 - $joins['flaggedpages'] = array( 'LEFT JOIN', 'page_id = fp_page_id' );
283 - }
 276+ wfRunHooks('GoogleNewsSitemap::Query', array($params, &$joins, &$conditions));
284277
285 - switch( $params['stable'] ) {
286 - case self::OPT_ONLY:
287 - $conditions[] = 'fp_stable IS NOT NULL ';
288 - break;
289 - case self::OPT_EXCLUDE:
290 - $conditions['fp_stable'] = null;
291 - break;
292 - }
293 - switch( $params['quality'] ) {
294 - case self::OPT_ONLY:
295 - $conditions[] = 'fp_quality >= 1';
296 - break;
297 - case self::OPT_EXCLUDE:
298 - $conditions['fp_quality'] = 0;
299 - break;
300 - }
301 - }
302 -
303278 switch ( $params['redirects'] ) {
304279 case self::OPT_ONLY:
305280 $conditions['page_is_redirect'] = 1;
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -500,6 +500,9 @@
501501 # Stable dump hook
502502 $wgHooks['WikiExporter::dumpStableQuery'][] = 'FlaggedRevsHooks::stableDumpQuery';
503503
 504+# GNSM category hooks
 505+$wgHooks['GoogleNewsSitemap::Query'][] = 'FlaggedRevsHooks::gnsmQueryModifier';
 506+
504507 # Duplicate flagged* tables in parserTests.php
505508 $wgHooks['ParserTestTables'][] = 'FlaggedRevsTestHooks::onParserTestTables';
506509 # Integration tests
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.hooks.php
@@ -1000,4 +1000,32 @@
10011001 }
10021002 return false; // final
10031003 }
 1004+
 1005+ public static function gnsmQueryModifier( array $params, array &$joins, array &$conditions ) {
 1006+ $filterSet = array( GoogleNewsSitemap::OPT_ONLY, GoogleNewsSitemap::OPT_EXCLUDE );
 1007+ # Either involves the same JOIN here...
 1008+ if ( isset( $filterSet[ $params['stable'] ] ) || isset( $filterSet[ $params['quality'] ] ) ) {
 1009+ $joins['flaggedpages'] = array( 'LEFT JOIN', 'page_id = fp_page_id' );
 1010+ }
 1011+
 1012+ switch( $params['stable'] ) {
 1013+ case GoogleNewsSitemap::OPT_ONLY:
 1014+ $conditions[] = 'fp_stable IS NOT NULL ';
 1015+ break;
 1016+ case GoogleNewsSitemap::OPT_EXCLUDE:
 1017+ $conditions['fp_stable'] = null;
 1018+ break;
 1019+ }
 1020+
 1021+ switch( $params['quality'] ) {
 1022+ case GoogleNewsSitemap::OPT_ONLY:
 1023+ $conditions[] = 'fp_quality >= 1';
 1024+ break;
 1025+ case GoogleNewsSitemap::OPT_EXCLUDE:
 1026+ $conditions['fp_quality'] = 0;
 1027+ break;
 1028+ }
 1029+
 1030+ return true;
 1031+ }
10041032 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r87233MFT r86451: FR changes for GNSMdemon01:21, 2 May 2011
r87236Fix GoogleNewsSitemap flagged revs support, which was rather broken....bawolff05:46, 2 May 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79236Convert the SQL to use DataBase::select and some more general cleanupsgigs05:13, 30 December 2010

Status & tagging log