SyncUtils: give NULL on nested intermediate NULL

fixes #2474
fixes #2584
This commit is contained in:
Thomas Gelf 2022-11-03 08:07:07 +01:00
parent 2a37db1115
commit b91cbd97b4
2 changed files with 6 additions and 2 deletions

View File

@ -19,6 +19,7 @@ v1.10.2 (unreleased)
* FIX: triggering Sync manually produced an error on PostgreSQL (#2636) * FIX: triggering Sync manually produced an error on PostgreSQL (#2636)
* FIX: purge stopped working for objects with uppercase characters (#2627) * FIX: purge stopped working for objects with uppercase characters (#2627)
* FIX: Notification Apply rule is now possible (wasn't since v1.8) (#2142, #2634) * FIX: Notification Apply rule is now possible (wasn't since v1.8) (#2142, #2634)
* FIX: nested property access with intermediate NULL values now gives NULL (#2474, #2584)
### Configuration Baskets ### Configuration Baskets
* FEATURE: more details shown in error messages related to invalid characters (#2646) * FEATURE: more details shown in error messages related to invalid characters (#2646)

View File

@ -91,6 +91,9 @@ class SyncUtils
if (! property_exists($row, $main)) { if (! property_exists($row, $main)) {
return null; return null;
} }
if ($row->$main === null) {
return null;
}
if (! is_object($row->$main)) { if (! is_object($row->$main)) {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(sprintf(
@ -107,12 +110,12 @@ class SyncUtils
/** /**
* Fill variables in the given string pattern * Fill variables in the given string pattern
* *
* This replaces all occurances of ${var_name} with the corresponding * This replaces all occurrences of ${var_name} with the corresponding
* property $row->var_name of the given row object. Missing variables are * property $row->var_name of the given row object. Missing variables are
* replaced by an empty string. This works also fine in case there are * replaced by an empty string. This works also fine in case there are
* multiple variables to be found in your string. * multiple variables to be found in your string.
* *
* @param string $string String with opional variables/placeholders * @param string $string String with optional variables/placeholders
* @param object $row stdClass object providing property values * @param object $row stdClass object providing property values
* *
* @return string * @return string