r71496 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71495‎ | r71496 | r71497 >
Date:18:18, 23 August 2010
Author:kaldari
Status:ok
Tags:
Comment:
some fixes to r71382
Modified paths:
  • /trunk/extensions/CentralNotice/SpecialCentralNotice.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php
@@ -706,6 +706,7 @@
707707 }
708708 $dbr = wfGetDB( DB_SLAVE );
709709
 710+ // Get campaign info from database
710711 $row = $dbr->selectRow( 'cn_notices',
711712 array(
712713 'not_id',
@@ -720,17 +721,11 @@
721722 array( 'not_name' => $notice ),
722723 __METHOD__
723724 );
724 - $res = $dbr->select( 'cn_notice_languages',
725 - 'nl_language',
726 - array( 'nl_notice_id' => $row->not_id ),
727 - __METHOD__
728 - );
729 - $project_languages = array();
730 - foreach ( $res as $langRow ) {
731 - $project_languages[] = $langRow->nl_language;
732 - }
733725
734726 if ( $row ) {
 727+ // Get all languages associated with the campaign
 728+ $noticeLanguages = $this->getNoticeLanguages( $notice );
 729+
735730 // Build Html
736731 $htmlOut = '';
737732 $htmlOut .= Xml::tags( 'h2', null, wfMsg( 'centralnotice-notice-heading', $notice ) );
@@ -760,7 +755,7 @@
761756 // Languages
762757 $htmlOut .= Xml::openElement( 'tr' );
763758 $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), wfMsgHtml( 'yourlanguage' ) );
764 - $htmlOut .= Xml::tags( 'td', array(), $this->languageMultiSelector( $project_languages ) );
 759+ $htmlOut .= Xml::tags( 'td', array(), $this->languageMultiSelector( $noticeLanguages ) );
765760 $htmlOut .= Xml::closeElement( 'tr' );
766761 // Enabled
767762 $htmlOut .= Xml::openElement( 'tr' );
@@ -1091,7 +1086,7 @@
10921087 $eNoticeName = htmlspecialchars( $noticeName );
10931088 $row = $dbr->selectRow( 'cn_notices', 'not_id', array( 'not_name' => $eNoticeName ) );
10941089 $languages = array();
1095 - if ( $dbr->numRows( $row ) > 0 ) {
 1090+ if ( $row ) {
10961091 $res = $dbr->select( 'cn_notice_languages', 'nl_language', array( 'nl_notice_id' => $row->not_id ) );
10971092 foreach ( $res as $langRow ) {
10981093 $languages[] = $langRow->nl_language;
@@ -1297,11 +1292,12 @@
12981293
12991294 // Remove disassociated languages
13001295 $removeLanguages = array_diff( $oldLanguages, $newLanguages );
1301 - if ( !empty( $removeLanguages ) ) {
 1296+ if ( $removeLanguages ) {
13021297 $res = $dbw->delete( 'cn_notice_languages',
13031298 array( 'nl_notice_id' => $row->not_id, 'nl_language' => $removeLanguages )
13041299 );
13051300 }
 1301+
13061302 $dbw->commit();
13071303 }
13081304

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r71382fixing table field names per r68666, fixing inserts and deletes per r68580, r...kaldari22:34, 20 August 2010

Status & tagging log