forked from friendica/friendica-addons
[various] Replace references to UTC_TIMESTAMP in SQL queries with a DateTimeFormat generated parameter
This commit is contained in:
parent
0de0faa44f
commit
fd29c1a074
2 changed files with 11 additions and 11 deletions
|
@ -50,8 +50,8 @@ function public_server_cron($a, $b)
|
||||||
{
|
{
|
||||||
Logger::notice("public_server: cron start");
|
Logger::notice("public_server: cron start");
|
||||||
|
|
||||||
$users = DBA::selectToArray('user', [], ["`account_expires_on` < UTC_TIMESTAMP() + INTERVAL ? DAY AND
|
$users = DBA::selectToArray('user', [], ["`account_expires_on` > ? AND `account_expires_on` < ?
|
||||||
`account_expires_on` > ? AND `expire_notification_sent` <= ?", 5, DBA::NULL_DATETIME, DBA::NULL_DATETIME]);
|
AND `expire_notification_sent` <= ?", DBA::NULL_DATETIME, DateTimeFormat::utc('now + 5 days'), DBA::NULL_DATETIME]);
|
||||||
foreach ($users as $rr) {
|
foreach ($users as $rr) {
|
||||||
DI::notify()->createFromArray([
|
DI::notify()->createFromArray([
|
||||||
'type' => Notification\Type::SYSTEM,
|
'type' => Notification\Type::SYSTEM,
|
||||||
|
@ -68,8 +68,8 @@ function public_server_cron($a, $b)
|
||||||
|
|
||||||
$nologin = DI::config()->get('public_server', 'nologin', false);
|
$nologin = DI::config()->get('public_server', 'nologin', false);
|
||||||
if ($nologin) {
|
if ($nologin) {
|
||||||
$users = DBA::selectToArray('user', [], ["NOT `account_expired` AND `login_date` <= ? AND `register_date` < UTC_TIMESTAMP() - INTERVAL ? DAY AND `account_expires_on` <= ?",
|
$users = DBA::selectToArray('user', [], ["NOT `account_expired` AND `login_date` <= ? AND `register_date` < ? AND `account_expires_on` <= ?",
|
||||||
DBA::NULL_DATETIME, $nologin, DBA::NULL_DATETIME]);
|
DBA::NULL_DATETIME, DateTimeFormat::utc('now - ' . (int)$nologin . ' days'), DBA::NULL_DATETIME]);
|
||||||
foreach ($users as $rr) {
|
foreach ($users as $rr) {
|
||||||
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
||||||
DBA::update('user', $fields, ['uid' => $rr['uid']]);
|
DBA::update('user', $fields, ['uid' => $rr['uid']]);
|
||||||
|
@ -78,8 +78,8 @@ function public_server_cron($a, $b)
|
||||||
|
|
||||||
$flagusers = DI::config()->get('public_server', 'flagusers', false);
|
$flagusers = DI::config()->get('public_server', 'flagusers', false);
|
||||||
if ($flagusers) {
|
if ($flagusers) {
|
||||||
$users = DBA::selectToArray('user', [], ["NOT `account_expired` AND `login_date` < UTC_TIMESTAMP() - INTERVAL ? DAY AND `account_expires_on` <= ? AND `page-flags` = ?",
|
$users = DBA::selectToArray('user', [], ["NOT `account_expired` AND `login_date` < ? AND `account_expires_on` <= ? AND `page-flags` = ?",
|
||||||
$flagusers, DBA::NULL_DATETIME, User::PAGE_FLAGS_NORMAL]);
|
DateTimeFormat::utc('now - ' . (int)$flagusers . ' days'), DBA::NULL_DATETIME, User::PAGE_FLAGS_NORMAL]);
|
||||||
foreach ($users as $rr) {
|
foreach ($users as $rr) {
|
||||||
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
$fields = ['account_expires_on' => DateTimeFormat::utc('now +6 days')];
|
||||||
DBA::update('user', $fields, ['uid' => $rr['uid']]);
|
DBA::update('user', $fields, ['uid' => $rr['uid']]);
|
||||||
|
@ -89,8 +89,8 @@ function public_server_cron($a, $b)
|
||||||
$flagposts = DI::config()->get('public_server', 'flagposts');
|
$flagposts = DI::config()->get('public_server', 'flagposts');
|
||||||
$flagpostsexpire = DI::config()->get('public_server', 'flagpostsexpire');
|
$flagpostsexpire = DI::config()->get('public_server', 'flagpostsexpire');
|
||||||
if ($flagposts && $flagpostsexpire) {
|
if ($flagposts && $flagpostsexpire) {
|
||||||
$users = DBA::selectToArray('user', [], ["NOT `account_expired` AND `login_date` < UTC_TIMESTAMP() - INTERVAL ? DAY AND `account_expires_on` <= ? AND NOT `expire` AND `page-flags` = ?",
|
$users = DBA::selectToArray('user', [], ["NOT `account_expired` AND `login_date` < ? AND `account_expires_on` <= ? AND NOT `expire` AND `page-flags` = ?",
|
||||||
$flagposts, DBA::NULL_DATETIME, User::PAGE_FLAGS_NORMAL]);
|
DateTimeFormat::utc('now - ' . (int)$flagposts . ' days'), DBA::NULL_DATETIME, User::PAGE_FLAGS_NORMAL]);
|
||||||
foreach ($users as $rr) {
|
foreach ($users as $rr) {
|
||||||
DBA::update('user', ['expire' => $flagpostsexpire], ['uid' => $rr['uid']]);
|
DBA::update('user', ['expire' => $flagpostsexpire], ['uid' => $rr['uid']]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,8 @@ function testdrive_register_account($a,$b) {
|
||||||
|
|
||||||
|
|
||||||
function testdrive_cron($a,$b) {
|
function testdrive_cron($a,$b) {
|
||||||
$users = DBA::selectToArray('user', [], ["`account_expires_on` < UTC_TIMESTAMP() + INTERVAL ? DAY AND `expire_notification_sent` <= ?",
|
$users = DBA::selectToArray('user', [], ["`account_expires_on` < ? AND `expire_notification_sent` <= ?",
|
||||||
5, DBA::NULL_DATETIME]);
|
DateTimeFormat::utc('now + 5 days'), DBA::NULL_DATETIME]);
|
||||||
foreach($users as $rr) {
|
foreach($users as $rr) {
|
||||||
DI::notify()->createFromArray([
|
DI::notify()->createFromArray([
|
||||||
'type' => Notification\Type::SYSTEM,
|
'type' => Notification\Type::SYSTEM,
|
||||||
|
@ -63,7 +63,7 @@ function testdrive_cron($a,$b) {
|
||||||
DBA::update('user', ['expire_notification_sent' => DateTimeFormat::utcNow()], ['uid' => $rr['uid']]);
|
DBA::update('user', ['expire_notification_sent' => DateTimeFormat::utcNow()], ['uid' => $rr['uid']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = DBA::selectToArray('user', [], ["`account_expired` AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL ? DAY", 5]);
|
$users = DBA::selectToArray('user', [], ["`account_expired` AND `account_expires_on` < ?", DateTimeFormat::utc('now - 5 days')]);
|
||||||
foreach($users as $rr) {
|
foreach($users as $rr) {
|
||||||
User::remove($rr['uid']);
|
User::remove($rr['uid']);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue