r88634 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88633‎ | r88634 | r88635 >
Date:06:18, 23 May 2011
Author:bawolff
Status:ok
Tags:
Comment:
Do not include hidden categories in the list of keywords on gnsm output.
Modified paths:
  • /trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php
@@ -501,9 +501,9 @@
502502 * @param Title $title
503503 * @return Array of String: list of keywords
504504 */
505 - public function getKeywords( $title ) {
 505+ public function getKeywords( Title $title ) {
506506 wfProfileIn( __METHOD__ );
507 - $cats = $title->getParentCategories();
 507+ $cats = $this->getVisibleCategories( $title );
508508 $res = array();
509509
510510 # the following code is based (stolen) from r56954 of flagged revs.
@@ -520,7 +520,7 @@
521521 if ( !$targetTitle ) {
522522 continue;
523523 }
524 - $target = $targetTitle->getPrefixedDBkey();
 524+ $target = $targetTitle->getDBkey();
525525 $mapTo = trim( $mapping[1] );
526526
527527 if ( $mapTo === '__MASK__' ) {
@@ -531,7 +531,7 @@
532532 }
533533 }
534534 }
535 - foreach ( $cats as $cat => $val ) {
 535+ foreach ( $cats as $cat ) {
536536 if ( !isset( $catMask[$cat] ) ) {
537537 if ( isset( $catMap[$cat] ) ) {
538538 // Its mapped.
@@ -546,4 +546,48 @@
547547 wfProfileOut( __METHOD__ );
548548 return $res;
549549 }
 550+
 551+ /**
 552+ * Get all non-hidden categories for a title.
 553+ *
 554+ * Kind of similar to title::getParentCategories.
 555+ *
 556+ * @param Title $title Which title to get the categories for.
 557+ * @return Array of String's that are the (non-prefixed) db-keys of the cats.
 558+ */
 559+ private function getVisibleCategories ( Title $title ) {
 560+ $dbr = wfGetDB( DB_SLAVE );
 561+
 562+ $where = array(
 563+ 'cl_from' => $title->getArticleID(),
 564+ 'pp_propname' => null
 565+ );
 566+
 567+ $joins = array(
 568+ 'page' => array(
 569+ 'LEFT OUTER JOIN',
 570+ array( 'page_namespace' => NS_CATEGORY, 'page_title=cl_to' )
 571+ ),
 572+ 'page_props' => array(
 573+ 'LEFT OUTER JOIN',
 574+ array( 'pp_page=page_id', 'pp_propname' => 'hiddencat' )
 575+ )
 576+ );
 577+
 578+ $res = $dbr->select(
 579+ array( 'categorylinks', 'page', 'page_props' ),
 580+ 'cl_to',
 581+ $where,
 582+ __METHOD__,
 583+ array(), /* options */
 584+ $joins
 585+ );
 586+ $finalResult = array();
 587+ if ( $res !== false ) {
 588+ foreach( $res as $row ) {
 589+ $finalResult[] = $row->cl_to;
 590+ }
 591+ }
 592+ return $finalResult;
 593+ }
550594 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r88707MFT r88634demon01:08, 24 May 2011

Status & tagging log