r90642 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90641‎ | r90642 | r90643 >
Date:00:55, 23 June 2011
Author:kaldari
Status:ok (Comments)
Tags:
Comment:
pull banners with a single db query per comment at r89294
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.db.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/CentralNotice.db.php
@@ -132,40 +132,39 @@
133133 $templates = array();
134134
135135 if ( $campaigns ) {
136 - foreach ( $campaigns as $campaignId ) {
137 - $res = $dbr->select(
138 - array(
139 - 'cn_notices',
140 - 'cn_assignments',
141 - 'cn_templates'
142 - ),
143 - array(
144 - 'tmp_name',
145 - 'tmp_weight',
146 - 'tmp_display_anon',
147 - 'tmp_display_account',
148 - 'tmp_fundraising',
149 - 'tmp_landing_pages'
150 - ),
151 - array(
152 - 'cn_notices.not_id' => $campaignId,
153 - 'cn_notices.not_id = cn_assignments.not_id',
154 - 'cn_assignments.tmp_id = cn_templates.tmp_id'
155 - ),
156 - __METHOD__
 136+ $res = $dbr->select(
 137+ array(
 138+ 'cn_notices',
 139+ 'cn_assignments',
 140+ 'cn_templates'
 141+ ),
 142+ array(
 143+ 'tmp_name',
 144+ 'tmp_weight',
 145+ 'tmp_display_anon',
 146+ 'tmp_display_account',
 147+ 'tmp_fundraising',
 148+ 'tmp_landing_pages',
 149+ 'not_name'
 150+ ),
 151+ array(
 152+ 'cn_notices.not_id' => $campaigns,
 153+ 'cn_notices.not_id = cn_assignments.not_id',
 154+ 'cn_assignments.tmp_id = cn_templates.tmp_id'
 155+ ),
 156+ __METHOD__
 157+ );
 158+
 159+ foreach ( $res as $row ) {
 160+ $templates[] = array(
 161+ 'name' => $row->tmp_name,
 162+ 'weight' => intval( $row->tmp_weight ),
 163+ 'display_anon' => intval( $row->tmp_display_anon ),
 164+ 'display_account' => intval( $row->tmp_display_account ),
 165+ 'fundraising' => intval( $row->tmp_fundraising ),
 166+ 'landing_pages' => $row->tmp_landing_pages,
 167+ 'campaign' => $row->not_name
157168 );
158 -
159 - foreach ( $res as $row ) {
160 - $templates[] = array(
161 - 'name' => $row->tmp_name,
162 - 'weight' => intval( $row->tmp_weight ),
163 - 'display_anon' => intval( $row->tmp_display_anon ),
164 - 'display_account' => intval( $row->tmp_display_account ),
165 - 'fundraising' => intval( $row->tmp_fundraising ),
166 - 'landing_pages' => $row->tmp_landing_pages,
167 - 'campaign' => CentralNotice::getNoticeName( $campaignId )
168 - );
169 - }
170169 }
171170 }
172171 return $templates;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89294return the campaigns in the banner lists - 1st step for new tracking featureskaldari21:44, 1 June 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   19:18, 24 June 2011

Not set up to test locally but it looks right.

#Comment by Kaldari (talk | contribs)   19:42, 24 June 2011

Cool. I've tested it locally and it seems to work as expected. ~~~~

Status & tagging log