fix all other occurences of db_quoteinterval()

This commit is contained in:
Mike Macgirvin 2024-04-05 07:39:24 +11:00
parent 33e034f7d4
commit 42a88ca015
17 changed files with 58 additions and 58 deletions

View file

@ -303,8 +303,8 @@ function mark_orphan_hubsxchans()
$r = q("update hubloc set hubloc_deleted = 1 where hubloc_deleted = 0
and hubloc_network in ('nomad','zot6') and hubloc_connected != '0001-01-01 00:00:00' hubloc_connected < %s - interval %s",
db_utcnow(), db_quoteinterval('36 day')
and hubloc_network in ('nomad','zot6') and hubloc_connected != '0001-01-01 00:00:00' and hubloc_connected < %s - %s",
db_utcnow(), db_quoteinterval('36 day', true)
);
$r = q("select hubloc_id, hubloc_hash from hubloc where hubloc_deleted = 1 and hubloc_orphancheck = 0");
@ -589,9 +589,9 @@ function random_profile()
for ($i = 0; $i < $retryrandom; $i++) {
$r = q("select xchan_url, xchan_hash from xchan left join hubloc on hubloc_hash = xchan_hash where
xchan_hidden = 0 and xchan_network in ('nomad','zot6') and xchan_deleted = 0 and hubloc_deleted = 0
and hubloc_connected > %s - interval %s order by $randfunc limit 1",
and hubloc_connected > %s - %s order by $randfunc limit 1",
db_utcnow(),
db_quoteinterval('30 day')
db_quoteinterval('30 day', true)
);
if (!$r) {

View file

@ -554,11 +554,11 @@ function update_birthdays()
$r = q(
"SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_dob > %s + interval %s and abook_dob < %s + interval %s",
WHERE abook_dob > %s + %s and abook_dob < %s + %s",
db_utcnow(),
db_quoteinterval('7 day'),
db_quoteinterval('7 day', true),
db_utcnow(),
db_quoteinterval('14 day')
db_quoteinterval('14 day', true)
);
if ($r) {
foreach ($r as $rr) {

View file

@ -3504,8 +3504,8 @@ function item_expire($uid,$days,$comment_days = 7) {
$r = q("SELECT id FROM item
WHERE uid = %d
AND created < %s - INTERVAL %s
AND commented < %s - INTERVAL %s
AND created < %s - %s
AND commented < %s - %s
AND item_retained = 0
AND item_thread_top = 1
AND resource_type = ''
@ -3513,9 +3513,9 @@ function item_expire($uid,$days,$comment_days = 7) {
$sql_extra $item_normal LIMIT $expire_limit ",
intval($uid),
db_utcnow(),
db_quoteinterval(intval($days) . ' DAY'),
db_quoteinterval(intval($days) . ' DAY', true),
db_utcnow(),
db_quoteinterval(intval($comment_days) . ' DAY')
db_quoteinterval(intval($comment_days) . ' DAY', true)
);
if (! $r) {

View file

@ -33,9 +33,9 @@ class Checksites implements DaemonInterface
}
$r = q(
"select * from site where site_dead = 0 and site_update < %s - INTERVAL %s and site_type = %d $sql_options ",
"select * from site where site_dead = 0 and site_update < %s - %s and site_type = %d $sql_options ",
db_utcnow(),
db_quoteinterval($days . ' DAY'),
db_quoteinterval($days . ' DAY', true),
intval(SITE_TYPE_ZOT)
);

View file

@ -42,17 +42,17 @@ class Cron_daily implements DaemonInterface
// expire any read notifications over a month old
q(
"delete from notify where seen = 1 and created < %s - INTERVAL %s",
"delete from notify where seen = 1 and created < %s - %s",
db_utcnow(),
db_quoteinterval('60 DAY')
db_quoteinterval('60 DAY', true)
);
// expire any unread notifications over a year old
q(
"delete from notify where seen = 0 and created < %s - INTERVAL %s",
"delete from notify where seen = 0 and created < %s - %s",
db_utcnow(),
db_quoteinterval('1 YEAR')
db_quoteinterval('1 YEAR', true)
);
// expire old delivery reports
@ -63,17 +63,17 @@ class Cron_daily implements DaemonInterface
}
q(
"delete from dreport where dreport_time < %s - INTERVAL %s",
"delete from dreport where dreport_time < %s - %s",
db_utcnow(),
db_quoteinterval($keep_reports . ' DAY')
db_quoteinterval($keep_reports . ' DAY', true)
);
// delete accounts that did not submit email verification within 3 days
$r = q(
"select * from register where password = 'verify' and created < %s - INTERVAL %s",
"select * from register where password = 'verify' and created < %s - %s",
db_utcnow(),
db_quoteinterval('3 DAY')
db_quoteinterval('3 DAY', true)
);
if ($r) {
foreach ($r as $rv) {

View file

@ -35,11 +35,11 @@ class Cron_weekly implements DaemonInterface
$r = q(
"select channel_id from channel where channel_removed = 1 and
channel_deleted > %s - INTERVAL %s and channel_deleted < %s - INTERVAL %s",
channel_deleted > %s - %s and channel_deleted < %s - %s",
db_utcnow(),
db_quoteinterval('21 DAY'),
db_quoteinterval('21 DAY', true),
db_utcnow(),
db_quoteinterval('10 DAY')
db_quoteinterval('10 DAY', true)
);
if ($r) {
foreach ($r as $rv) {
@ -50,9 +50,9 @@ class Cron_weekly implements DaemonInterface
// get rid of ancient poco records
q(
"delete from xlink where xlink_updated < %s - INTERVAL %s and xlink_static = 0 ",
"delete from xlink where xlink_updated < %s - %s and xlink_static = 0 ",
db_utcnow(),
db_quoteinterval('14 DAY')
db_quoteinterval('14 DAY', true)
);
// Check for dead sites

View file

@ -21,9 +21,9 @@ class Expire implements DaemonInterface
// so notifications should have been delivered.
$pending_deletes = q(
"select id from item where item_deleted = 1 and item_pending_remove = 0 and changed < %s - INTERVAL %s",
"select id from item where item_deleted = 1 and item_pending_remove = 0 and changed < %s - %s",
db_utcnow(),
db_quoteinterval('4 DAY')
db_quoteinterval('4 DAY', true)
);
if ($pending_deletes) {
foreach ($pending_deletes as $item) {

View file

@ -38,9 +38,9 @@ class Importdoc implements DaemonInterface
}
// remove old files that weren't updated (indicates they were most likely deleted).
$i = q(
"select * from item where item_type = 5 and edited < %s - INTERVAL %s",
"select * from item where item_type = 5 and edited < %s - %s",
db_utcnow(),
db_quoteinterval('14 DAY')
db_quoteinterval('14 DAY', true)
);
if ($i) {
foreach ($i as $iv) {

View file

@ -167,10 +167,10 @@ class Onepoll implements DaemonInterface
$r = q(
"SELECT xlink_id from xlink
where xlink_xchan = '%s' and xlink_updated > %s - INTERVAL %s and xlink_static = 0 limit 1",
where xlink_xchan = '%s' and xlink_updated > %s - %s and xlink_static = 0 limit 1",
intval($contact['xchan_hash']),
db_utcnow(),
db_quoteinterval('7 DAY')
db_quoteinterval('7 DAY', true)
);
if (! $r) {
Socgraph::poco_load($contact['xchan_hash'], $contact['xchan_connurl']);

View file

@ -18,27 +18,27 @@ class Queue implements DaemonInterface
// delete all queue items more than 3 days old
// but first mark these sites dead if we haven't heard from them in a month
$oldqItems = q("select outq_posturl from outq where outq_created < %s - INTERVAL %s",
$oldqItems = q("select outq_posturl from outq where outq_created < %s - %s",
db_utcnow(),
db_quoteinterval('3 DAY')
db_quoteinterval('3 DAY', true)
);
if ($oldqItems) {
foreach ($oldqItems as $qItem) {
$h = parse_url($qItem['outq_posturl']);
$site_url = $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : '');
q("update site set site_dead = 1 where site_dead = 0 and site_url = '%s' and site_update < %s - INTERVAL %s",
q("update site set site_dead = 1 where site_dead = 0 and site_url = '%s' and site_update < %s - %s",
dbesc($site_url),
db_utcnow(),
db_quoteinterval('1 MONTH')
db_quoteinterval('1 MONTH', true)
);
}
logger('Removing ' . count($oldqItems) . ' old queue entries');
}
q("DELETE FROM outq WHERE outq_created < %s - INTERVAL %s",
q("DELETE FROM outq WHERE outq_created < %s - %s",
db_utcnow(),
db_quoteinterval('3 DAY')
db_quoteinterval('3 DAY', true)
);
$deliveries = [];

View file

@ -181,11 +181,11 @@ class Activity
$site_url = unparse_url(['scheme' => $parsed['scheme'], 'host' => $parsed['host'], 'port' => ((array_key_exists('port', $parsed) && intval($parsed['port'])) ? $parsed['port'] : 0)]);
q(
"update site set site_update = '%s' where site_url = '%s' and site_update < %s - INTERVAL %s",
"update site set site_update = '%s' where site_url = '%s' and site_update < %s - %s",
dbesc(Time::convert()),
dbesc($site_url),
db_utcnow(),
db_quoteinterval('1 DAY')
db_quoteinterval('1 DAY', true)
);
// check for a valid signature, but only if this is not an actor object. If it is signed, it must be valid.

View file

@ -1181,10 +1181,10 @@ class Channel
$r = q(
"select * from item where item_wall = 1 and item_deleted = 0 and uid = %d
and created > %s - INTERVAL %s and resource_type = '' order by created",
and created > %s - %s and resource_type = '' order by created",
intval($channel_id),
db_utcnow(),
db_quoteinterval('3 MONTH')
db_quoteinterval('3 MONTH', true)
);
if ($r) {
$ret['item'] = [];

View file

@ -168,9 +168,9 @@ class Chatroom
if (intval($x[0]['cr_expire'])) {
$r = q(
"delete from chat where created < %s - INTERVAL %s and chat_room = %d",
"delete from chat where created < %s - %s and chat_room = %d",
db_utcnow(),
db_quoteinterval(intval($x[0]['cr_expire']) . ' MINUTE'),
db_quoteinterval(intval($x[0]['cr_expire']) . ' MINUTE', true),
intval($x[0]['cr_id'])
);
}

View file

@ -118,9 +118,9 @@ class Socgraph {
}
}
q(
"delete from xchat where xchat_edited < %s - INTERVAL %s and xchat_xchan = '%s' ",
"delete from xchat where xchat_edited < %s - %s and xchat_xchan = '%s' ",
db_utcnow(),
db_quoteinterval('7 DAY'),
db_quoteinterval('7 DAY', true),
dbesc($xchan)
);
}
@ -241,10 +241,10 @@ class Socgraph {
logger("poco_load: loaded $total entries", LOGGER_DEBUG);
q(
"delete from xlink where xlink_xchan = '%s' and xlink_updated < %s - INTERVAL %s and xlink_static = 0",
"delete from xlink where xlink_xchan = '%s' and xlink_updated < %s - %s and xlink_static = 0",
dbesc($xchan),
db_utcnow(),
db_quoteinterval('7 DAY')
db_quoteinterval('7 DAY', true)
);
}
@ -344,10 +344,10 @@ class Socgraph {
logger("ap_poco_load: loaded $total entries", LOGGER_DEBUG);
q(
"delete from xlink where xlink_xchan = '%s' and xlink_updated < %s - INTERVAL %s and xlink_static = 0",
"delete from xlink where xlink_xchan = '%s' and xlink_updated < %s - %s and xlink_static = 0",
dbesc($xchan),
db_utcnow(),
db_quoteinterval('7 DAY')
db_quoteinterval('7 DAY', true)
);
return true;

View file

@ -70,10 +70,10 @@ class Verify
public static function purge(string $type, string $interval): void
{
q(
"delete from verify where vtype = '%s' and created < ( %s - INTERVAL %s )",
"delete from verify where vtype = '%s' and created < ( %s - %s )",
dbesc($type),
db_utcnow(),
db_quoteinterval($interval)
db_quoteinterval($interval, true)
);
}
}

View file

@ -135,9 +135,9 @@ class Ping extends Controller
*/
q(
"delete from chatpresence where cp_last < %s - INTERVAL %s and cp_client != 'auto' ",
"delete from chatpresence where cp_last < %s - %s and cp_client != 'auto' ",
db_utcnow(),
db_quoteinterval('3 MINUTE')
db_quoteinterval('3 MINUTE', true)
);

View file

@ -66,9 +66,9 @@ class Register extends Controller
$max_dailies = intval(get_config('system', 'max_daily_registrations'));
if ($max_dailies) {
$r = q(
"select count(account_id) as total from account where account_created > %s - INTERVAL %s",
"select count(account_id) as total from account where account_created > %s - %s",
db_utcnow(),
db_quoteinterval('1 day')
db_quoteinterval('1 day', true)
);
if ($r && intval($r[0]['total']) >= $max_dailies) {
notice(t('Maximum daily site registrations exceeded. Please try again tomorrow.') . EOL);
@ -240,9 +240,9 @@ class Register extends Controller
$max_dailies = intval(get_config('system', 'max_daily_registrations'));
if ($max_dailies) {
$r = q(
"select count(account_id) as total from account where account_created > %s - INTERVAL %s",
"select count(account_id) as total from account where account_created > %s - %s",
db_utcnow(),
db_quoteinterval('1 day')
db_quoteinterval('1 day', true)
);
if ($r && $r[0]['total'] >= $max_dailies) {
logger('max daily registrations exceeded.');