silence phpstorm's false positive error messages on db intervals

This commit is contained in:
Mike Macgirvin 2024-04-05 07:22:06 +11:00
parent ad6cf9f712
commit 33e034f7d4
3 changed files with 9 additions and 8 deletions

View file

@ -307,9 +307,10 @@ function dbescdate($date)
return DBA::$dba->escape($date); return DBA::$dba->escape($date);
} }
function db_quoteinterval($txt) function db_quoteinterval($txt, $includeInterval = false)
{ {
return DBA::$dba->quote_interval($txt); $returnText = $includeInterval ? 'INTERVAL ' : '';
return $returnText . DBA::$dba->quote_interval($txt);
} }
function dbesc_identifier($str) function dbesc_identifier($str)

View file

@ -92,9 +92,9 @@ class Cron implements DaemonInterface
// Ensure that every channel pings their directory occasionally. // Ensure that every channel pings their directory occasionally.
$interval = floatval(Config::Get('system','delivery_interval', 2)); $interval = floatval(Config::Get('system','delivery_interval', 2));
$r = q( $r = q(
"select channel_id from channel where channel_dirdate < %s - INTERVAL %s and channel_removed = 0", "select channel_id from channel where channel_dirdate < %s - %s and channel_removed = 0",
db_utcnow(), db_utcnow(),
db_quoteinterval('7 DAY') db_quoteinterval('7 DAY', true)
); );
if ($r) { if ($r) {
foreach ($r as $rr) { foreach ($r as $rr) {
@ -162,9 +162,9 @@ class Cron implements DaemonInterface
$r = q( $r = q(
"select xchan_photo_l, xchan_hash from xchan where xchan_photo_l != '' and xchan_photo_m = '' "select xchan_photo_l, xchan_hash from xchan where xchan_photo_l != '' and xchan_photo_m = ''
and xchan_photo_date < %s - INTERVAL %s", and xchan_photo_date < %s - %s",
db_utcnow(), db_utcnow(),
db_quoteinterval('1 DAY') db_quoteinterval('1 DAY', true)
); );
if ($r) { if ($r) {
require_once('include/photo_factory.php'); require_once('include/photo_factory.php');

View file

@ -1567,10 +1567,10 @@ class Item extends Controller
if (PConfig::Get($profile_uid, 'system', 'suppress_duplicates', true) && (!$orig_post)) { if (PConfig::Get($profile_uid, 'system', 'suppress_duplicates', true) && (!$orig_post)) {
$z = q( $z = q(
"select created from item where uid = %d and created > %s - INTERVAL %s and body = '%s' limit 1", "select created from item where uid = %d and created > %s - %s and body = '%s' limit 1",
intval($profile_uid), intval($profile_uid),
db_utcnow(), db_utcnow(),
db_quoteinterval('2 MINUTE'), db_quoteinterval('2 MINUTE', true),
dbesc($body) dbesc($body)
); );