mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Fixed that /api/system/db-changed-time
always returned the current time
This commit is contained in:
@@ -21,9 +21,14 @@ class ApiKeyService extends BaseService
|
||||
$apiKeyRow = $this->Database->api_keys()->where('api_key = :1 AND expires > :2 AND key_type = :3', $apiKey, date('Y-m-d H:i:s', time()), $keyType)->fetch();
|
||||
if ($apiKeyRow !== null)
|
||||
{
|
||||
// This should not change the database file modification time at this is used
|
||||
// to determine if REALLY something has changed
|
||||
$dbModTime = $this->DatabaseService->GetDbChangedTime();
|
||||
$apiKeyRow->update(array(
|
||||
'last_used' => date('Y-m-d H:i:s', time())
|
||||
));
|
||||
$this->DatabaseService->SetDbChangedTime($dbModTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@@ -68,4 +68,9 @@ class DatabaseService
|
||||
{
|
||||
return date('Y-m-d H:i:s', filemtime(GROCY_DATAPATH . '/grocy.db'));
|
||||
}
|
||||
|
||||
public function SetDbChangedTime($dateTime)
|
||||
{
|
||||
touch(GROCY_DATAPATH . '/grocy.db', strtotime($dateTime));
|
||||
}
|
||||
}
|
||||
|
@@ -18,9 +18,14 @@ class SessionService extends BaseService
|
||||
$sessionRow = $this->Database->sessions()->where('session_key = :1 AND expires > :2', $sessionKey, date('Y-m-d H:i:s', time()))->fetch();
|
||||
if ($sessionRow !== null)
|
||||
{
|
||||
// This should not change the database file modification time at this is used
|
||||
// to determine if REALLY something has changed
|
||||
$dbModTime = $this->DatabaseService->GetDbChangedTime();
|
||||
$sessionRow->update(array(
|
||||
'last_used' => date('Y-m-d H:i:s', time())
|
||||
));
|
||||
$this->DatabaseService->SetDbChangedTime($dbModTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user