r73959 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73958‎ | r73959 | r73960 >
Date:17:19, 29 September 2010
Author:kaldari
Status:ok
Tags:
Comment:
tentative fix for bug 25354 (abondoning custom variables), adding quotes per r73829
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.db.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialBannerLoader.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/SpecialBannerLoader.php
@@ -103,8 +103,12 @@
104104 */
105105 function getNoticeField( $match ) {
106106 $field = $match[1];
 107+ $params = array();
 108+ if ( $field == 'amount' ) {
 109+ $params = array( $this->formatNum( $this->getDonationAmount() ) );
 110+ }
107111 $message = "centralnotice-{$this->bannerName}-$field";
108 - $source = $this->getMessage( $message );
 112+ $source = $this->getMessage( $message, $params );
109113 return $source;
110114 }
111115
@@ -125,25 +129,25 @@
126130 * @param $msg The full name of the message
127131 * @return translated messsage string
128132 */
129 - private function getMessage( $msg ) {
130 - global $wgLang;
131 -
 133+ private function getMessage( $msg, $params = array() ) {
 134+ global $wgLang, $wgSitename;
 135+
132136 // A god-damned dirty hack! :D
133137 $oldLang = $wgLang;
 138+ $oldSitename = $wgSitename;
134139
 140+ $wgSitename = $this->siteName; // hack for {{SITENAME}}
135141 $wgLang = Language::factory( $this->language ); // hack for {{int:...}}
136 - $out = wfMsgExt( $msg, array( 'language' => $this->language, 'parsemag' ) );
137142
138 - // Restore global
 143+ $options = array( 'language' => $this->language, 'parsemag' );
 144+ array_unshift( $params, $options );
 145+ array_unshift( $params, $msg );
 146+ $out = call_user_func_array( 'wfMsgExt', $params );
 147+
 148+ // Restore global variables
139149 $wgLang = $oldLang;
140 -
141 - // Replace variables in banner with values
142 - $amountSub = strpos( $out, '$amount');
143 - if ( $amountSub !== false ) {
144 - $out = str_replace( '$amount', $this->formatNum( $this->getDonationAmount() ), $out );
145 - }
146 - $out = str_replace( '$sitename', $this->siteName, $out );
147 -
 150+ $wgSitename = $oldSitename;
 151+
148152 return $out;
149153 }
150154
Index: trunk/extensions/CentralNotice/CentralNotice.db.php
@@ -27,9 +27,9 @@
2828 $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
2929
3030 if ( !$date ) {
31 - $encTimestamp = $dbr->timestamp();
 31+ $encTimestamp = $dbr->addQuotes( $dbr->timestamp() );
3232 } else {
33 - $encTimestamp = $dbr->timestamp( $date );
 33+ $encTimestamp = $dbr->addQuotes( $dbr->timestamp( $date ) );
3434 }
3535
3636 $tables[] = "cn_notices";

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r73829fixing issues from r73095, additional not_project condition is redundant so r...kaldari22:27, 27 September 2010

Status & tagging log