mirror of
https://github.com/processwire/processwire.git
synced 2025-08-25 07:41:30 +02:00
Fix issue processwire/processwire-issues#1258
This commit is contained in:
@@ -2065,6 +2065,33 @@ class ProcessField extends Process implements ConfigurableModule {
|
|||||||
return $allowed;
|
return $allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare two diff context arrays and return the differences
|
||||||
|
*
|
||||||
|
* @param array $a1
|
||||||
|
* @param array $a2
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected function diffContextArray(array $a1, array $a2) {
|
||||||
|
$diff = array();
|
||||||
|
foreach($a1 as $k => $v) {
|
||||||
|
if(is_array($v)) {
|
||||||
|
if(!isset($a2[$k]) || !is_array($a2[$k])) {
|
||||||
|
$diff[$k] = $v;
|
||||||
|
} else {
|
||||||
|
$_diff = $this->diffContextArray($v, $a2[$k]);
|
||||||
|
if(count($_diff)) $diff[$k] = $_diff;
|
||||||
|
}
|
||||||
|
} else if(!array_key_exists($k, $a2)) {
|
||||||
|
$diff[$k] = $v;
|
||||||
|
} else if($a2[$k] !== $v) {
|
||||||
|
$diff[$k] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $diff;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save field in the context of a fieldgroup only
|
* Save field in the context of a fieldgroup only
|
||||||
*
|
*
|
||||||
@@ -2077,7 +2104,7 @@ class ProcessField extends Process implements ConfigurableModule {
|
|||||||
$this->fields->saveFieldgroupContext($this->field, $this->fieldgroup, $this->contextNamespace);
|
$this->fields->saveFieldgroupContext($this->field, $this->fieldgroup, $this->contextNamespace);
|
||||||
$this->saveRemoveOverrides();
|
$this->saveRemoveOverrides();
|
||||||
$newContextArray = $this->fieldgroup->getFieldContextArray($this->field->id);
|
$newContextArray = $this->fieldgroup->getFieldContextArray($this->field->id);
|
||||||
$diffContextArray = array_diff_assoc($newContextArray, $oldContextArray);
|
$diffContextArray = $this->diffContextArray($newContextArray, $oldContextArray);
|
||||||
if(count($diffContextArray)) {
|
if(count($diffContextArray)) {
|
||||||
$this->fieldChangedContext($this->field, $this->fieldgroup, $diffContextArray);
|
$this->fieldChangedContext($this->field, $this->fieldgroup, $diffContextArray);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user