diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/property.inc.php | 22 | ||||
-rw-r--r-- | inc/taskmanagercallback.inc.php | 20 | ||||
-rw-r--r-- | inc/trigger.inc.php | 13 |
3 files changed, 38 insertions, 17 deletions
diff --git a/inc/property.inc.php b/inc/property.inc.php index 3911b0d4..1b979982 100644 --- a/inc/property.inc.php +++ b/inc/property.inc.php @@ -33,24 +33,30 @@ class Property } /** - * Set value in property store. + * Set value in property store. Passing null or false as the value deletes the + * entry from the property table. * * @param string $key key of value to set - * @param string $value the value to store for $key + * @param string|null|false $value the value to store for $key * @param int $maxAgeMinutes how long to keep this entry around at least, in minutes. 0 for infinite */ public static function set($key, $value, $maxAgeMinutes = 0) { - if (self::$cache === false || self::get($key) != $value) { // Simple compare, so it works for numbers accidentally casted to string somewhere + if ($value === false || $value === null) { + Database::exec("DELETE FROM property WHERE name = :key", ['key' => $key]); + if (self::$cache !== false) { + unset(self::$cache[$key]); + } + } else { Database::exec("INSERT INTO property (name, value, dateline) VALUES (:key, :value, :dateline)" - . " ON DUPLICATE KEY UPDATE value = VALUES(value), dateline = VALUES(dateline)", array( + . " ON DUPLICATE KEY UPDATE value = VALUES(value), dateline = VALUES(dateline)", [ 'key' => $key, 'value' => $value, 'dateline' => ($maxAgeMinutes === 0 ? 0 : time() + ($maxAgeMinutes * 60)) - )); - } - if (self::$cache !== false) { - self::$cache[$key] = $value; + ]); + if (self::$cache !== false) { + self::$cache[$key] = $value; + } } } diff --git a/inc/taskmanagercallback.inc.php b/inc/taskmanagercallback.inc.php index 5f153baa..29bae262 100644 --- a/inc/taskmanagercallback.inc.php +++ b/inc/taskmanagercallback.inc.php @@ -87,7 +87,7 @@ class TaskmanagerCallback Eventlog::warning("handleCallback: Callback {$callback['cbfunction']} doesn't exist."); } else { if (empty($callback['args'])) - call_user_func($func, $status); + call_user_func($func, $status, null); else call_user_func($func, $status, unserialize($callback['args'])); } @@ -211,4 +211,22 @@ class TaskmanagerCallback RebootControl::connectionCheckCallback($task, $args); } + public static function ipxeVersionSet($task) + { + $mod = Module::get('serversetup'); + if ($mod === false) + return; + $mod->activate(1, false); + IPxeBuilder::setIPxeVersionCallback($task); + } + + public static function ipxeCompileDone($task) + { + $mod = Module::get('serversetup'); + if ($mod === false) + return; + $mod->activate(1, false); + IPxeBuilder::compileCompleteCallback($task); + } + } diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php index 5024b907..cd38ce98 100644 --- a/inc/trigger.inc.php +++ b/inc/trigger.inc.php @@ -14,20 +14,18 @@ class Trigger /** * Compile iPXE pxelinux menu. Needs to be done whenever the server's IP * address changes. - * - * @param boolean $force force recompilation even if it seems up to date - * @return boolean|string false if launching task failed, task-id otherwise + * + * @return string|false false if launching task failed, task-id otherwise */ - public static function ipxe() + public static function ipxe($taskId = null) { $hooks = Hook::load('ipxe-update'); - static $taskId = false; foreach ($hooks as $hook) { $ret = function($taskId) use ($hook) { $ret = include_once($hook->file); if (is_string($ret)) return $ret; - return isset($taskId) ? $taskId : false; + return $taskId; }; $ret = $ret($taskId); if (is_string($ret)) { @@ -36,8 +34,7 @@ class Trigger $taskId = $ret['id']; } } - Property::set('ipxe-task-id', $taskId, 15); - return $taskId; + return $taskId ?? false; } /** |