r72204 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72203‎ | r72204 | r72205 >
Date:17:30, 2 September 2010
Author:kaldari
Status:ok (Comments)
Tags:
Comment:
replacing var and @, removing htmlspecialchars() per comments at r72177
Modified paths:
  • /trunk/extensions/CentralNotice/BannerLoader.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/BannerLoader.php
@@ -4,8 +4,8 @@
55 * Generates banner HTML files
66 */
77 class BannerLoader extends UnlistedSpecialPage {
8 - var $project = 'wikipedia'; // Project name
9 - var $language = 'en'; // User language
 8+ public $project = 'wikipedia'; // Project name
 9+ public $language = 'en'; // User language
1010 protected $sharedMaxAge = 22; // Cache for ? hours on the server side
1111 protected $maxAge = 0; // No client-side banner caching so we get all impressions
1212 protected $contentType = 'text/html';
@@ -22,10 +22,10 @@
2323 $this->sendHeaders();
2424
2525 // Get user language from the query string
26 - $this->language = htmlspecialchars( $wgRequest->getText( 'language', 'en' ) );
 26+ $this->language = $wgRequest->getText( 'language', 'en' );
2727
2828 // Get project name from the query string
29 - $this->project = htmlspecialchars( $wgRequest->getText( 'project', 'wikipedia' ) );
 29+ $this->project = $wgRequest->getText( 'project', 'wikipedia' );
3030
3131 if ( $wgRequest->getText( 'banner' ) ) {
3232 $bannerName = htmlspecialchars( $wgRequest->getText( 'banner' ) );
@@ -146,7 +146,9 @@
147147 $count = intval( $wgMemc->get( 'centralnotice:counter' ) );
148148 if ( !$count ) {
149149 // Pull from dynamic counter
150 - $count = intval( @file_get_contents( $wgNoticeCounterSource ) );
 150+ wfSuppressWarnings();
 151+ $count = intval( file_get_contents( $wgNoticeCounterSource ) );
 152+ wfRestoreWarnings();
151153 if ( !$count ) {
152154 // Pull long-cached amount
153155 $count = intval( $wgMemc->get( 'centralnotice:counter:fallback' ) );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r72177initial version of BannerLoaderkaldari23:18, 1 September 2010

Comments

#Comment by Catrope (talk | contribs)   17:21, 8 September 2010
+	public $project = 'wikipedia'; // Project name
+	public $language = 'en'; // User language
[...]
+		$this->language = $wgRequest->getText( 'language', 'en' );
+		$this->project = $wgRequest->getText( 'project', 'wikipedia' );

This way you're storing the defaults twice, and only one is actually used.

Status & tagging log