r105696 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105695‎ | r105696 | r105697 >
Date:19:16, 9 December 2011
Author:yaron
Status:ok
Tags:
Comment:
Replaced hardcoded SQL with a Database::select() call
Modified paths:
  • /trunk/extensions/SemanticDrilldown/includes/SD_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/includes/SD_Utils.php
@@ -84,18 +84,26 @@
8585 */
8686 static function getOnlyExplicitlyShownCategories() {
8787 $shown_cats = array();
 88+
8889 $dbr = wfGetDB( DB_SLAVE );
89 - extract( $dbr->tableNames( 'page', 'page_props' ) );
90 - $cat_ns = NS_CATEGORY;
91 - $sql = "SELECT p.page_title FROM $page p JOIN $page_props pp ON p.page_id = pp.pp_page WHERE p.page_namespace = $cat_ns AND pp.pp_propname = 'showindrilldown' AND pp.pp_value = 'y'";
92 - $res = $dbr->query( $sql );
 90+ $res = $dbr->select(
 91+ array( 'p' => 'page', 'pp' => 'page_props' ),
 92+ 'p.page_title',
 93+ array(
 94+ 'p.page_namespace' => NS_CATEGORY,
 95+ 'pp.pp_propname' => 'showindrilldown',
 96+ 'pp.pp_value' => 'y'
 97+ ),
 98+ 'SDUtils::getOnlyExplicitlyShownCategories',
 99+ array( 'ORDER BY' => 'p.page_title' ),
 100+ array( 'pp' => array( 'JOIN', 'p.page_id = pp.pp_page' ) )
 101+ );
93102
94103 while ( $row = $dbr->fetchRow( $res ) ) {
95104 $shown_cats[] = str_replace( '_', ' ', $row[0] );
96105 }
97106 $dbr->freeResult( $res );
98107
99 - sort( $shown_cats );
100108 return $shown_cats;
101109 }
102110

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r105653Added handling for new $sdgHideCategoriesByDefault setting variableyaron05:38, 9 December 2011

Status & tagging log