r90668 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90667‎ | r90668 | r90669 >
Date:18:42, 23 June 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
Fix for r86722: pass the message 'dberrortext' unescaped to the output since it contains. I really don't like to pass unescaped messages to the output *sigh*
Modified paths:
  • /trunk/phase3/includes/db/DatabaseError.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseError.php
@@ -265,13 +265,18 @@
266266 */
267267 function getContentMessage( $html ) {
268268 if ( $this->useMessageCache() ) {
269 - $msg = $html ? 'dberrortext' : 'dberrortextcl';
270 - $ret = wfMsg( $msg, $this->getSQL(),
271 - $this->fname, $this->errno, $this->error );
272269 if ( $html ) {
273 - $ret = htmlspecialchars( $ret );
 270+ $msg = 'dberrortext';
 271+ $sql = htmlspecialchars( $this->getSQL() );
 272+ $fname = htmlspecialchars( $this->fname );
 273+ $error = htmlspecialchars( $this->error );
 274+ } else {
 275+ $msg = 'dberrortextcl';
 276+ $sql = $this->getSQL();
 277+ $fname = $this->fname;
 278+ $error = $this->error;
274279 }
275 - return $ret;
 280+ return wfMsg( $msg, $sql, $fname, $this->errno, $error );
276281 } else {
277282 return parent::getContentMessage( $html );
278283 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r95495Fix error that was reported as a fixme against r90668, not at fault though...reedy17:13, 25 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86722Added DBError::getContentMessage() to factorise common code; DBUnexpectedErro...ialex18:57, 22 April 2011

Comments

#Comment by Nikerabbit (talk | contribs)   18:51, 23 June 2011

Contains what?

#Comment by IAlex (talk | contribs)   18:56, 23 June 2011

HTML.

#Comment by Raymond (talk | contribs)   18:19, 24 August 2011

This can produce a PHP warning:

Warning:  htmlspecialchars() expects parameter 1 to be string, array given in D:\F_Programmierung\xampp\htdocs\wiki2\includes\db\DatabaseError.php on line 271
Screenshot
#Comment by Reedy (talk | contribs)   16:49, 25 August 2011

Can you reproduce this on demand Raymond?

If so, could you put a var_dump( $this->fname ); before line 271. I want to know if we should just work around it, or it's being setup incorrectly

#Comment by Raymond (talk | contribs)   16:54, 25 August 2011

Running same revision as before:

array(1) {
  ["campaign_id"]=>
  NULL
}
#Comment by Reedy (talk | contribs)   17:14, 25 August 2011

Marking ok again after fixing the actual issue in r95495 (which wasn't this rev)

Status & tagging log