Add debugging, but commented out

This commit is contained in:
Isaac Connor 2022-02-03 17:30:38 -05:00
parent ac39be33f5
commit a6dc7ba0fc
1 changed files with 7 additions and 0 deletions

View File

@ -237,10 +237,13 @@ class ZM_Object {
$changes = array();
if ($defaults) {
// FIXME: This code basically means that the new_values must be a full object, not a subset
// Perhaps if it only concerned itself with the keys of new_values
foreach ($defaults as $field => $type) {
if (isset($new_values[$field])) continue;
if (isset($this->defaults[$field])) {
//Debug("Setting default for $field");
if (is_array($this->defaults[$field])) {
$new_values[$field] = $this->defaults[$field]['default'];
} else {
@ -255,9 +258,11 @@ class ZM_Object {
if (array_key_exists($field, $this->defaults) && is_array($this->defaults[$field]) && isset($this->defaults[$field]['filter_regexp'])) {
if (is_array($this->defaults[$field]['filter_regexp'])) {
foreach ($this->defaults[$field]['filter_regexp'] as $regexp) {
//Debug("regexping array $field $value to " . preg_replace($regexp, '', trim($value)));
$value = preg_replace($regexp, '', trim($value));
}
} else {
//Debug("regexping $field $value to " . preg_replace($this->defaults[$field]['filter_regexp'], '', trim($value)));
$value = preg_replace($this->defaults[$field]['filter_regexp'], '', trim($value));
}
}
@ -265,10 +270,12 @@ class ZM_Object {
$old_value = $this->$field();
if (is_array($old_value)) {
$diff = array_recursive_diff($old_value, $value);
//Debug("$field array old: " .print_r($old_value, true) . " new: " . print_r($value, true). ' diff: '. print_r($diff, true));
if ( count($diff) ) {
$changes[$field] = $value;
}
} else if ( $this->$field() != $value ) {
//Debug("$field != $value");
$changes[$field] = $value;
}
} else if (property_exists($this, $field)) {