From 1ff2bc4f3c694b7c76df8e57056c51ca39a23a34 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Jan 2015 18:07:24 +0100 Subject: config module structure completed. Many other fixes. Hidden pw field support. --- inc/property.inc.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'inc/property.inc.php') diff --git a/inc/property.inc.php b/inc/property.inc.php index c16c8ad7..7c3b7d37 100644 --- a/inc/property.inc.php +++ b/inc/property.inc.php @@ -41,12 +41,14 @@ class Property */ private static function set($key, $value, $minage = 0) { - Database::exec("INSERT INTO property (name, value, dateline) VALUES (:key, :value, :dateline)" - . " ON DUPLICATE KEY UPDATE value = VALUES(value), dateline = VALUES(dateline)", array( - 'key' => $key, - 'value' => $value, - 'dateline' => ($minage === 0 ? 0 : time() + ($minage * 60)) - )); + if (self::$cache === false || self::get($key) != $value) { // Simple compare, so it works for numbers accidentally casted to string somewhere + Database::exec("INSERT INTO property (name, value, dateline) VALUES (:key, :value, :dateline)" + . " ON DUPLICATE KEY UPDATE value = VALUES(value), dateline = VALUES(dateline)", array( + 'key' => $key, + 'value' => $value, + 'dateline' => ($minage === 0 ? 0 : time() + ($minage * 60)) + )); + } if (self::$cache !== false) { self::$cache[$key] = $value; } @@ -181,5 +183,15 @@ class Property { return self::get('password-type', 'password'); } + + public static function setNeedsCallback($value) + { + return self::set('need-callback', $value, 5); + } + + public static function getNeedsCallback() + { + return self::get('need-callback', 0); + } } -- cgit v1.2.3-55-g7522