aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
authorDM42.Net (Matt Dent) <dentm42@dm42.net>2019-01-07 19:48:14 -0500
committerDM42.Net (Matt Dent) <dentm42@dm42.net>2019-01-07 19:48:14 -0500
commit563a5088be7e0c439e244ab9513404a97c3d6c44 (patch)
treeac70e8370a24b82f2a3e6e37252cb104f478a6cf /Zotlabs/Lib
parent48821a6da5832b5eb843503121871231f78b1103 (diff)
downloadvolse-hubzilla-563a5088be7e0c439e244ab9513404a97c3d6c44.tar.gz
volse-hubzilla-563a5088be7e0c439e244ab9513404a97c3d6c44.tar.bz2
volse-hubzilla-563a5088be7e0c439e244ab9513404a97c3d6c44.zip
Tweak to deal with changes that may happen within the same second.
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/PConfig.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/Zotlabs/Lib/PConfig.php b/Zotlabs/Lib/PConfig.php
index 5e5954c95..69f4de2db 100644
--- a/Zotlabs/Lib/PConfig.php
+++ b/Zotlabs/Lib/PConfig.php
@@ -131,14 +131,19 @@ class PConfig {
$dbvalue = ((is_array($value)) ? serialize($value) : $value);
$dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue);
+ $now = datetime_convert();
if (! $updated) {
- $updated = datetime_convert();
+ //Sometimes things happen fast... very fast.
+ //To make sure legitimate updates aren't rejected
+ //because not enough time has passed. We say our updates
+ //happened just a short time in the past rather than right now.
+ $updated = datetime_convert('UTC','UTC','-2 seconds');
}
$hash = hash('sha256',$family.':'.$key);
if (self::Get($uid, 'hz_delpconfig', $hash) !== false) {
- if (self::Get($uid, 'hz_delpconfig', $hash) > $updated) {
+ if (self::Get($uid, 'hz_delpconfig', $hash) > $now) {
logger('Refusing to update pconfig with outdated info (Item deleted more recently).', LOGGER_NORMAL, LOG_ERR);
return self::Get($uid,$family,$key);
} else {
@@ -173,7 +178,7 @@ class PConfig {
}
else {
- $new = (\App::$config[$uid][$family]['pcfgud:'.$key] < $updated);
+ $new = (\App::$config[$uid][$family]['pcfgud:'.$key] < $now);
if ($new) {
@@ -241,9 +246,9 @@ class PConfig {
if(is_null($uid) || $uid === false)
return false;
- $updated = ($updated) ? $updated : datetime_convert();
-
- $newer = (\App::$config[$uid][$family]['pcfgud:'.$key] < $updated);
+ $updated = ($updated) ? $updated : datetime_convert('UTC','UTC','-2 seconds');
+ $now = datetime_convert();
+ $newer = (\App::$config[$uid][$family]['pcfgud:'.$key] < $now);
if (! $newer) {
logger('Refusing to delete pconfig with outdated delete request.', LOGGER_NORMAL, LOG_ERR);