Replace references to NOW() in SQL queries with a DateTimeFormat generated parameter
This commit is contained in:
parent
80da47921e
commit
423892b814
|
@ -146,7 +146,7 @@ class DatabaseCache extends AbstractCache implements ICanCache
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($outdated) {
|
if ($outdated) {
|
||||||
return $this->dba->delete('cache', ['`expires` < NOW()']);
|
return $this->dba->delete('cache', ['`expires` < ?', DateTimeFormat::utcNow()]);
|
||||||
} else {
|
} else {
|
||||||
return $this->dba->delete('cache', ['`k` IS NOT NULL ']);
|
return $this->dba->delete('cache', ['`k` IS NOT NULL ']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Worker;
|
||||||
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear cache entries
|
* Clear cache entries
|
||||||
|
@ -31,15 +32,13 @@ class ClearCache
|
||||||
{
|
{
|
||||||
public static function execute()
|
public static function execute()
|
||||||
{
|
{
|
||||||
$a = DI::app();
|
|
||||||
|
|
||||||
// clear old cache
|
// clear old cache
|
||||||
DI::cache()->clear();
|
DI::cache()->clear();
|
||||||
|
|
||||||
// Delete the cached OEmbed entries that are older than three month
|
// Delete the cached OEmbed entries that are older than three month
|
||||||
DBA::delete('oembed', ["`created` < NOW() - INTERVAL 3 MONTH"]);
|
DBA::delete('oembed', ["`created` < ?", DateTimeFormat::utc('now - 3 months')]);
|
||||||
|
|
||||||
// Delete the cached "parsed_url" entries that are expired
|
// Delete the cached "parsed_url" entries that are expired
|
||||||
DBA::delete('parsed_url', ["`expires` < NOW()"]);
|
DBA::delete('parsed_url', ["`expires` < ?", DateTimeFormat::utcNow()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user