r45749 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45748‎ | r45749 | r45750 >
Date:21:22, 14 January 2009
Author:catrope
Status:resolved (Comments)
Tags:
Comment:
API: Clean up invalid UTF-8 in the result before feeding it to the formatter. This should fix bug 15261 (trimmed multibyte chars) and bug 16262 (chars like \x0f)
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)
  • /trunk/phase3/includes/api/ApiResult.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiResult.php
@@ -186,6 +186,15 @@
187187 ApiResult :: setElement($data, $name, $value); // Add named element
188188 }
189189
 190+ /**
 191+ * Ensure all values in this result are valid UTF-8.
 192+ */
 193+ public function cleanUpUTF8()
 194+ {
 195+ $data = & $this->getData();
 196+ array_walk_recursive($data, array('UtfNormal', 'cleanUp'));
 197+ }
 198+
190199 public function execute() {
191200 ApiBase :: dieDebug(__METHOD__, 'execute() is not supported on Result object');
192201 }
Index: trunk/phase3/includes/api/ApiMain.php
@@ -438,6 +438,7 @@
439439 * Print results using the current printer
440440 */
441441 protected function printResult($isError) {
 442+ $this->getResult()->cleanupUTF8();
442443 $printer = $this->mPrinter;
443444 $printer->profileIn();
444445
Index: trunk/phase3/RELEASE-NOTES
@@ -50,6 +50,7 @@
5151 * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions
5252 and listing all deleted pages possible
5353 * (bug 16844) Added clcategories parameter to prop=categories
 54+* (bug 15261, 16262) API no longer outputs invalid UTF-8
5455
5556 === Languages updated in 1.15 ===
5657

Follow-up revisions

RevisionCommit summaryAuthorDate
r45766Fix regression from r45749: only UTF-8 normalize stringscatrope10:26, 15 January 2009
r45956Fix up r45749: do is_string() check in the caller insteadcatrope09:26, 21 January 2009

Comments

#Comment by Nikerabbit (talk | contribs)   09:17, 15 January 2009

Had this new error in Betawiki, but have no time to investigate right now, but I suspect it may be because of this change.

PHP Catchable fatal error:  Object of class RSSFeed could not be converted to string in /var/www/w/includes/normal/UtfNormal.php on line 221
#Comment by Catrope (talk | contribs)   10:26, 15 January 2009

Fixed in r45766

#Comment by Brion VIBBER (talk | contribs)   22:02, 20 January 2009

That fix is bad -- fix the calling code instead.

#Comment by Catrope (talk | contribs)   22:03, 20 January 2009
#Comment by Catrope (talk | contribs)   09:27, 21 January 2009

Fixed in r45956

Status & tagging log