1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-24 15:23:11 +02:00

Fix issue processwire/processwire-issues#653 Inputfield parent issue causing out of memory errors when two buttons lacking name attributes

This commit is contained in:
Ryan Cramer
2018-08-06 08:21:21 -04:00
parent c9a210ec35
commit 6882abe40a
2 changed files with 21 additions and 1 deletions

View File

@@ -493,12 +493,31 @@ abstract class Inputfield extends WireData implements Module {
*/
public function setParent(InputfieldWrapper $parent) {
if($this->parent && $this->parent instanceof InputfieldWrapper && $this->parent !== $parent) {
$this->parent->remove($this);
$oldRootParent = $this->getRootParent();
if(!$oldRootParent) $oldRootParent = $this->parent;
$newRootParent = $parent->getRootParent();
if(!$newRootParent) $newRootParent = $parent;
if($oldRootParent === $newRootParent) {
// if field staying in the same form, remove from previous parent
$this->parent->remove($this);
}
}
$this->parent = $parent;
return $this;
}
/**
* Unset any previously set parent
*
* #pw-internal
* @return $this
*
*/
public function unsetParent() {
$this->parent = null;
return $this;
}
/**
* Get this Inputfields parent InputfieldWrapper, or NULL if it doesnt have one.
*

View File

@@ -416,6 +416,7 @@ class InputfieldWrapper extends Inputfield implements \Countable, \IteratorAggre
array_push($wrappers, $inputfield);
}
$inputfield->unsetParent();
$wrapper->add($inputfield);
}