r69490 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69489‎ | r69490 | r69491 >
Date:20:59, 17 July 2010
Author:daniel
Status:deferred
Tags:
Comment:
fixed record flattening
Modified paths:
  • /trunk/extensions/DataTransclusion/WebDataTransclusionSource.php (modified) (history)
  • /trunk/extensions/DataTransclusion/XmlDataTransclusionSource.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DataTransclusion/WebDataTransclusionSource.php
@@ -228,16 +228,16 @@
229229 $r[ $k ] = $v;
230230 }
231231
232 - return $r;
233 - } else {
234 - return $rec;
235 - }
 232+ $rec = $r;
 233+ }
236234
237235 foreach ( $rec as $k => $v ) {
238236 if ( !is_null( $v ) && !is_string( $v ) && !is_int( $v ) ) {
239237 $rec[ $k ] = $this->asString( $v );
240238 }
241239 }
 240+
 241+ return $rec;
242242 }
243243
244244 public function resolvePath( $data, $path, $split = true ) {
Index: trunk/extensions/DataTransclusion/XmlDataTransclusionSource.php
@@ -59,6 +59,7 @@
6060
6161 public function resolvePath( $dom, $xpath ) {
6262 $lookup = new DOMXPath( $dom->ownerDocument );
 63+
6364 $res = $lookup->query( $xpath, $dom );
6465
6566 if ( $res instanceof DOMNodeList ) {
@@ -88,28 +89,4 @@
8990 return "$v";
9091 }
9192
92 - public function flattenRecord( $rec ) {
93 - $rec = parent::flattenRecord( $rec );
94 -
95 - if ( !$rec ) return $rec;
96 -
97 - foreach ( $rec as $k => $v ) {
98 - if ( is_object($v) ) {
99 - if ( $v instanceof DOMNodeList ) {
100 - $v = $v->item( 0 );
101 - }
102 -
103 - if ( $v instanceof DOMNamedNodeMap ) {
104 - $v = $v->item( 0 );
105 - }
106 -
107 - if ( $v instanceof DOMNode ) {
108 - $rec[ $k ] = $v->textContent;
109 - }
110 - }
111 - }
112 -
113 - return $rec;
114 - }
115 -
11693 }

Status & tagging log