r37075 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37074‎ | r37075 | r37076 >
Date:22:44, 4 July 2008
Author:brion
Status:old
Tags:
Comment:
Revert r37009 -- turns out you can do these structures, it's just very nonobvious. :)

An anonymous sub-array allows creating sub-elements in addition to the attributes:
array(
'attrib1' => 'val1',
'attrib2' => 'val2',
array(
'tag' => 'stuff',
'tag2' => 'stuff2',
)
)
Modified paths:
  • /trunk/phase3/includes/api/ApiFormatXml.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiFormatXml.php
@@ -83,13 +83,6 @@
8484
8585 switch (gettype($elemValue)) {
8686 case 'array' :
87 - if (isset ($elemValue['_attribs'])) {
88 - $attribValues = $elemValue['_attribs'];
89 - unset( $elemValue['_attribs'] );
90 - } else {
91 - $attribValues = null;
92 - }
93 -
9487 if (isset ($elemValue['*'])) {
9588 $subElemContent = $elemValue['*'];
9689 if ($this->mDoubleQuote)
@@ -120,8 +113,6 @@
121114 unset ($elemValue[$subElemId]);
122115 }
123116 }
124 -
125 - $elemValue = wfArrayMerge( $attribValues, $elemValue ); // wtf
126117
127118 if (is_null($subElemIndName) && !empty ($indElements))
128119 ApiBase :: dieDebug(__METHOD__, "($elemName, ...) has integer keys without _element value. Use ApiResult::setIndexedTagName().");
@@ -132,7 +123,7 @@
133124 if (!is_null($subElemContent)) {
134125 $this->printText($indstr . wfElement($elemName, $elemValue, $subElemContent));
135126 } elseif (empty ($indElements) && empty ($subElements)) {
136 - $this->printText($indstr . wfElement($elemName, $elemValue));
 127+ $this->printText($indstr . wfElement($elemName, $elemValue));
137128 } else {
138129 $this->printText($indstr . wfElement($elemName, $elemValue, null));
139130

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r37009Have been playing with custom API modules and been a bit frustrated with the ...brion21:25, 3 July 2008

Status & tagging log