summaryrefslogtreecommitdiffstats
path: root/inc/property.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2021-04-20 16:40:25 +0200
committerSimon Rettberg2021-04-20 16:40:25 +0200
commit7c5748d3a6bc12ece61ccf782047f6200b79b325 (patch)
treed409550975adb7e014dd919892d4e110e55f62c4 /inc/property.inc.php
parent[sysconfig] Enforce proper ldadp services running on reboot/install (diff)
downloadslx-admin-7c5748d3a6bc12ece61ccf782047f6200b79b325.tar.gz
slx-admin-7c5748d3a6bc12ece61ccf782047f6200b79b325.tar.xz
slx-admin-7c5748d3a6bc12ece61ccf782047f6200b79b325.zip
[serversetup-bwlp-ipxe] Add iPXE version selector
Diffstat (limited to 'inc/property.inc.php')
-rw-r--r--inc/property.inc.php22
1 files changed, 14 insertions, 8 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;
+ }
}
}