Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved the call to clone the template node to the start of the next() …

…method

to overcome Segmentation fault in php-fpm 5.3.10 which appears to dislike using insertBefore with a node that already exists within the template

-- Iain Dooley
  • Loading branch information...
commit a1a989fac6c7843eaa4236aecca9c07c4e06cd68 1 parent 221fb05
@Kroc authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 domtemplate.php
View
9 domtemplate.php
@@ -283,7 +283,8 @@ public function addClass ($query, $new_class) {
} return $this;
}
- //add a className to an existing class attribute (this is shared between `setValue` & `addClass`
+ //add a className to an existing class attribute
+ //(this is shared between `setValue` & `addClass`)
private function setClassNode ($DOMNode, $class) {
//check if the class node already has the className (don't add twice)
if (!in_array ($class, explode (' ', $DOMNode->nodeValue)))
@@ -418,6 +419,10 @@ public function __construct ($DOMNode, $namespaces=array ()) {
}
public function next () {
+ //reset the template
+ //(this is done first due to a segfault with PHP-FPM 5.3.10 which appears to dislike using `insertBefore`
+ // with a node that already exists within the template. thanks goes to Iain Dooley for discovering this bug)
+ $this->DOMNode = $this->template->cloneNode (true);
//when we insert the newly templated item, use it as the reference node for the next item and so on.
$this->refNode = ($this->refNode->parentNode->lastChild === $this->DOMNode)
? $this->refNode->parentNode->appendChild ($this->DOMNode)
@@ -425,8 +430,6 @@ public function next () {
//inbetween. this means that the list you are templating doesn't have to be wrapped in an element!
: $this->refNode->parentNode->insertBefore ($this->DOMNode, $this->refNode->nextSibling)
;
- //reset the template
- $this->DOMNode = $this->template->cloneNode (true);
return $this;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.