r47447 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47446‎ | r47447 | r47448 >
Date:12:41, 18 February 2009
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
Proposed fix for bug 17552. Also the name of the function should be changed, because there's nothing internal about it.
Modified paths:
  • /trunk/phase3/includes/api/ApiResult.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiResult.php
@@ -221,8 +221,12 @@
222222 */
223223 public function setIndexedTagName_internal( $path, $tag ) {
224224 $data = & $this->mData;
225 - foreach((array)$path as $p)
 225+ foreach((array)$path as $p) {
 226+ if ( !isset( $data[$p] ) ) {
 227+ $data[$p] = array();
 228+ }
226229 $data = & $data[$p];
 230+ }
227231 if(is_null($data))
228232 return;
229233 $this->setIndexedTagName($data, $tag);

Comments

#Comment by Catrope (talk | contribs)   14:17, 18 February 2009

Looks fine to me.

About the name of the function: the _internal part is there because this function sets a tag name on something that's already *inside* the result object, as opposed to setIndexedTagName(), which sets a tag name on a user-supplied array *outside* the result object. The data in the result object is not directly modifiable from the outside (anymore, to ensure result size integrity), which is why a separate function is needed.

Status & tagging log