r110132 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110131‎ | r110132 | r110133 >
Date:15:57, 27 January 2012
Author:gregchiasson
Status:resolved (Comments)
Tags:aft 
Comment:
Fixes issues raised in commits from last night:
- r110069 - Use rawParams (didn't know that existed) for the span, which allows escaping of the rest of the translation message.
- r110068 - Call text() instead of nothing in feedbackHead(), to prevent double-escaping.
- r110070 - Call escaped() instead of text() on articlefeedbackv5-updates-since, to prevent not-escaping.
- r110086 - Make sure $date is defined, in addition to not calling timeanddate() on invalid/null timestamps.
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php
@@ -113,7 +113,7 @@
114114 'articlefeedbackv5-discussion-page' => 'Talk',
115115 'articlefeedbackv5-whats-this' => 'Help',
116116 'articlefeedbackv5-invalid-page-id' => 'Invalid page ID',
117 - 'articlefeedbackv5-percent-found' => '<span class="stat-marker positive">$1%</span> found what they were looking for',
 117+ 'articlefeedbackv5-percent-found' => '$1 found what they were looking for',
118118 'articlefeedbackv5-overall-rating' => 'Rating: $1/5',
119119 'articlefeedbackv5-special-title' => '==Feedback==',
120120 'articleFeedbackv5-table-caption-dailyhighsandlows' => 'Today\'s highs and lows',
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -296,6 +296,7 @@
297297 // Taken from the Moodbar extension.
298298 $now = wfTimestamp( TS_UNIX );
299299 $timestamp = wfTimestamp( TS_UNIX, $record[0]->af_created );
 300+ $date;
300301
301302 // Relative dates for 48 hours, normal timestamps later.
302303 if( $timestamp > ( $now - ( 86400 * 2 ) ) ) {
@@ -305,7 +306,6 @@
306307 $date = wfMessage( 'articleFeedbackv5-comment-ago', $time )->escaped();
307308 } elseif( $timestamp ) {
308309 $date = $wgLang->timeanddate($record[0]->af_created );
309 - } else {
310310 }
311311
312312 $details = Html::openElement( 'div', array(
@@ -327,7 +327,7 @@
328328 if( $record[0]->age > 0 ) {
329329 $details .= Linker::link(
330330 Title::newFromText( $record[0]->page_title ),
331 - wfMessage( 'articlefeedbackv5-updates-since', $record[0]->age )->text(),
 331+ wfMessage( 'articlefeedbackv5-updates-since', $record[0]->age )->escaped(),
332332 array(),
333333 array(
334334 'action' => 'historysubmit',
@@ -602,7 +602,7 @@
603603 . Html::element( 'span', array( 'class' => 'icon' ) )
604604 . Html::element( 'span',
605605 array( 'class' => 'result' ),
606 - wfMessage( $message, $gender, $extra )
 606+ wfMessage( $message, $gender, $extra )->text()
607607 )
608608 . Html::closeElement( 'h3' );
609609 }
Index: trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php
@@ -137,12 +137,14 @@
138138 );
139139
140140 if ( $found ) {
 141+ $class = $found > 50 ? 'positive' : 'negative';
 142+ $span = "<span class='stat-marker $class'>$found%</span>";
141143 $out->addHtml(
142144 Html::openElement(
143145 'div',
144146 array( 'id' => 'articleFeedbackv5-percent-found-wrap' )
145147 )
146 - . $this->msg( 'articlefeedbackv5-percent-found', $found )->plain() # Can't escape this, need the <span> tag to parse.
 148+ . $this->msg( 'articlefeedbackv5-percent-found' )->rawParams( $span )->escaped()
147149 . Html::closeElement( 'div' )
148150 );
149151 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r110156AFT5 - Followup to r110132, fixes untranslated percentage in span tag, and us...gregchiasson19:36, 27 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r110068AFT5:...gregchiasson19:23, 26 January 2012
r110069AFT5 - explicitly declare this as plain, per comments on r109390gregchiasson19:41, 26 January 2012
r110070ATF5 - fix issues from r109258 (not calling text() on messages) - one of the ...gregchiasson19:56, 26 January 2012
r110086AFT5 - SQL statements to rebuild the rollup tables using only bucket 1, and a...gregchiasson21:57, 26 January 2012

Comments

#Comment by Reedy (talk | contribs)   16:00, 27 January 2012

What is this for?

+		$date;
#Comment by 😂 (talk | contribs)   17:22, 27 January 2012

$date was undefined in r110086, though it makes more sense to define it with something like "" or another default.

#Comment by Raymond (talk | contribs)   19:08, 27 January 2012

Now % is hardcoded again. But some languages use a space between number and %. You should use the core message 'percent' here. Or '%$1'.

+			$span  = "$found%";

I suggest something like (untested):

$span = Html::rawElement( 'span', 'class' => "stat-marker $class", wfMsg( 'percent', $found ) )

Status & tagging log