Index: branches/wmf/1.19wmf1/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.body.php |
— | — | @@ -283,6 +283,7 @@ |
284 | 284 | if ( !self::$isFilePage && self::$forceClickToViewImages ) { |
285 | 285 | $tagToReplace = 'img'; |
286 | 286 | $tagToReplaceNodes = $doc->getElementsByTagName( $tagToReplace ); |
| 287 | + $tagToReplaceNodesCollection = array(); |
287 | 288 | foreach ( $tagToReplaceNodes as $tagToReplaceNode ) { |
288 | 289 | if ( $tagToReplaceNode ) { |
289 | 290 | $alt = $tagToReplaceNode->getAttribute( 'alt' ); |
— | — | @@ -291,9 +292,13 @@ |
292 | 293 | if ( $alt ) { |
293 | 294 | $spanNode->setAttribute( 'title', $alt ); |
294 | 295 | } |
295 | | - $tagToReplaceNode->parentNode->replaceChild( $spanNode, $tagToReplaceNode ); |
| 296 | + $tagToReplaceNodesCollection[] = array( 'tagToReplaceNode' => $tagToReplaceNode, 'spanNode' => $spanNode ); |
296 | 297 | } |
297 | 298 | } |
| 299 | + |
| 300 | + foreach ( $tagToReplaceNodesCollection as $element ) { |
| 301 | + $element['tagToReplaceNode']->parentNode->replaceChild( $element['spanNode'], $element['tagToReplaceNode'] ); |
| 302 | + } |
298 | 303 | } |
299 | 304 | |
300 | 305 | $zeroRatedLinks = $xpath->query( "//a[not(contains(@class,'external'))]" ); |