Sync: fix issues with PHP 5.3

This commit is contained in:
Thomas Gelf 2015-12-23 15:10:37 +01:00
parent 17f3394178
commit 2df368f4c7
1 changed files with 15 additions and 3 deletions

View File

@ -9,6 +9,14 @@ use Icinga\Exception\IcingaException;
class Sync class Sync
{ {
protected $modify = array();
protected $remove = array();
protected $create = array();
protected $errors = array();
/** /**
* Constructor. No direct initialization allowed right now. Please use one * Constructor. No direct initialization allowed right now. Please use one
* of the available static factory methods * of the available static factory methods
@ -132,7 +140,7 @@ class Sync
* *
* @return mixed * @return mixed
*/ */
protected function getSpecificValue($row, $var) public function getSpecificValue($row, $var)
{ {
if (strpos($var, '.') === false) { if (strpos($var, '.') === false) {
if (! property_exists($row, $var)) { if (! property_exists($row, $var)) {
@ -170,8 +178,10 @@ class Sync
return $this->getSpecificValue($row, $m[1]); return $this->getSpecificValue($row, $m[1]);
} }
$func = function ($match) use ($row) { // PHP 5.3 :(
return $this->getSpecificValue($row, $match[1]); $self = $this;
$func = function ($match) use ($self, $row) {
return $self->getSpecificValue($row, $match[1]);
}; };
return preg_replace_callback('/\${([A-Za-z0-9\._-]+)}/', $func, $string); return preg_replace_callback('/\${([A-Za-z0-9\._-]+)}/', $func, $string);
@ -386,11 +396,13 @@ class Sync
if (! $found) { if (! $found) {
$object->markForRemoval(); $object->markForRemoval();
$this->remove[] = $object;
} }
} }
// TODO: This should be noticed or removed: // TODO: This should be noticed or removed:
if (! $object->$objectKey) { if (! $object->$objectKey) {
$this->errors[] = $object;
$ignore[] = $key; $ignore[] = $key;
} }
} }