From fb9544badd66043bf7ee5a7566ba288ad7da29fa Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 25 Sep 2016 17:06:13 -0700 Subject: null_date conversion; phase 1 --- Zotlabs/Daemon/Cron.php | 6 +++--- Zotlabs/Daemon/Externals.php | 2 +- Zotlabs/Daemon/Onepoll.php | 2 +- Zotlabs/Daemon/Poller.php | 6 +++--- Zotlabs/Lib/ThreadItem.php | 2 +- Zotlabs/Module/Admin.php | 2 +- Zotlabs/Module/Profiles.php | 2 +- Zotlabs/Module/Removeaccount.php | 2 +- Zotlabs/Module/Removeme.php | 2 +- Zotlabs/Module/Settings/Tokens.php | 2 +- include/account.php | 4 ++-- include/channel.php | 2 +- include/conversation.php | 2 +- include/datetime.php | 2 +- include/dir_fns.php | 2 +- include/feedutils.php | 4 ++-- include/import.php | 8 ++++---- include/items.php | 10 +++++----- 18 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php index 613c2e705..924667b05 100644 --- a/Zotlabs/Daemon/Cron.php +++ b/Zotlabs/Daemon/Cron.php @@ -43,14 +43,14 @@ class Cron { // expire any expired mail - q("delete from mail where expires != '%s' and expires < %s ", + q("delete from mail where expires > '%s' and expires < %s ", dbesc(NULL_DATE), db_utcnow() ); // expire any expired items - $r = q("select id from item where expires != '%s' and expires < %s + $r = q("select id from item where expires > '%s' and expires < %s and item_deleted = 0 ", dbesc(NULL_DATE), db_utcnow() @@ -64,7 +64,7 @@ class Cron { // delete expired access tokens - $r = q("select atoken_id from atoken where atoken_expires != '%s' and atoken_expires < %s", + $r = q("select atoken_id from atoken where atoken_expires > '%s' and atoken_expires < %s", dbesc(NULL_DATE), db_utcnow() ); diff --git a/Zotlabs/Daemon/Externals.php b/Zotlabs/Daemon/Externals.php index 24cfe64ec..a9988a509 100644 --- a/Zotlabs/Daemon/Externals.php +++ b/Zotlabs/Daemon/Externals.php @@ -58,7 +58,7 @@ class Externals { } if($url) { - if($r[0]['site_pull'] !== NULL_DATE) + if($r[0]['site_pull'] > NULL_DATE) $mindate = urlencode(datetime_convert('','',$r[0]['site_pull'] . ' - 1 day')); else { $days = get_config('externals','since_days'); diff --git a/Zotlabs/Daemon/Onepoll.php b/Zotlabs/Daemon/Onepoll.php index bebf8bf17..33b244dc5 100644 --- a/Zotlabs/Daemon/Onepoll.php +++ b/Zotlabs/Daemon/Onepoll.php @@ -54,7 +54,7 @@ class Onepoll { logger("onepoll: poll: ({$contact['id']}) IMPORTER: {$importer['xchan_name']}, CONTACT: {$contact['xchan_name']}"); - $last_update = ((($contact['abook_updated'] === $contact['abook_created']) || ($contact['abook_updated'] === NULL_DATE)) + $last_update = ((($contact['abook_updated'] === $contact['abook_created']) || ($contact['abook_updated'] <= NULL_DATE)) ? datetime_convert('UTC','UTC','now - 7 days') : datetime_convert('UTC','UTC',$contact['abook_updated'] . ' - 2 days') ); diff --git a/Zotlabs/Daemon/Poller.php b/Zotlabs/Daemon/Poller.php index 75efbf8f7..e4bc9c143 100644 --- a/Zotlabs/Daemon/Poller.php +++ b/Zotlabs/Daemon/Poller.php @@ -117,7 +117,7 @@ class Poller { // if we've never connected with them, start the mark for death countdown from now - if($c == NULL_DATE) { + if($c <= NULL_DATE) { $r = q("update abook set abook_connected = '%s' where abook_id = %d", dbesc(datetime_convert()), intval($contact['abook_id']) @@ -171,7 +171,7 @@ class Poller { } if($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) { - $r = q("SELECT u.ud_addr, u.ud_id, u.ud_last FROM updates AS u INNER JOIN (SELECT ud_addr, max(ud_id) AS ud_id FROM updates WHERE ( ud_flags & %d ) = 0 AND ud_addr != '' AND ( ud_last = '%s' OR ud_last > %s - INTERVAL %s ) GROUP BY ud_addr) AS s ON s.ud_id = u.ud_id ", + $r = q("SELECT u.ud_addr, u.ud_id, u.ud_last FROM updates AS u INNER JOIN (SELECT ud_addr, max(ud_id) AS ud_id FROM updates WHERE ( ud_flags & %d ) = 0 AND ud_addr != '' AND ( ud_last <= '%s' OR ud_last > %s - INTERVAL %s ) GROUP BY ud_addr) AS s ON s.ud_id = u.ud_id ", intval(UPDATE_FLAGS_UPDATED), dbesc(NULL_DATE), db_utcnow(), db_quoteinterval('7 DAY') @@ -182,7 +182,7 @@ class Poller { // If they didn't respond when we attempted before, back off to once a day // After 7 days we won't bother anymore - if($rr['ud_last'] != NULL_DATE) + if($rr['ud_last'] > NULL_DATE) if($rr['ud_last'] > datetime_convert('UTC','UTC', 'now - 1 day')) continue; Master::Summon(array('Onedirsync',$rr['ud_id'])); diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index f50b9680e..120a34a19 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -344,7 +344,7 @@ class ThreadItem { 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'), 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), 'editedtime' => (($item['edited'] != $item['created']) ? sprintf( t('last edited: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r')) : ''), - 'expiretime' => (($item['expires'] !== NULL_DATE) ? sprintf( t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r')):''), + 'expiretime' => (($item['expires'] > NULL_DATE) ? sprintf( t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r')):''), 'lock' => $lock, 'verified' => $verified, 'unverified' => $unverified, diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php index e6a29fd8d..e3702992f 100644 --- a/Zotlabs/Module/Admin.php +++ b/Zotlabs/Module/Admin.php @@ -87,7 +87,7 @@ class Admin extends \Zotlabs\Web\Controller { // list total user accounts, expirations etc. $accounts = array(); - $r = q("SELECT COUNT(*) AS total, COUNT(CASE WHEN account_expires > %s THEN 1 ELSE NULL END) AS expiring, COUNT(CASE WHEN account_expires < %s AND account_expires != '%s' THEN 1 ELSE NULL END) AS expired, COUNT(CASE WHEN (account_flags & %d)>0 THEN 1 ELSE NULL END) AS blocked FROM account", + $r = q("SELECT COUNT(*) AS total, COUNT(CASE WHEN account_expires > %s THEN 1 ELSE NULL END) AS expiring, COUNT(CASE WHEN account_expires < %s AND account_expires > '%s' THEN 1 ELSE NULL END) AS expired, COUNT(CASE WHEN (account_flags & %d)>0 THEN 1 ELSE NULL END) AS blocked FROM account", db_utcnow(), db_utcnow(), dbesc(NULL_DATE), diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index 4b05182c2..788673296 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -724,7 +724,7 @@ class Profiles extends \Zotlabs\Web\Controller { '$marital' => marital_selector($r[0]['marital']), '$marital_min' => marital_selector_min($r[0]['marital']), '$with' => array('with', t("Who (if applicable)"), $r[0]['partner'], t('Examples: cathy123, Cathy Williams, cathy@example.com')), - '$howlong' => array('howlong', t('Since (date)'), ($r[0]['howlong'] === NULL_DATE ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong']))), + '$howlong' => array('howlong', t('Since (date)'), ($r[0]['howlong'] <= NULL_DATE ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong']))), '$sexual' => sexpref_selector($r[0]['sexual']), '$sexual_min' => sexpref_selector_min($r[0]['sexual']), '$about' => array('about', t('Tell us about yourself'), $r[0]['about']), diff --git a/Zotlabs/Module/Removeaccount.php b/Zotlabs/Module/Removeaccount.php index 9fac7838e..9d2bbd0de 100644 --- a/Zotlabs/Module/Removeaccount.php +++ b/Zotlabs/Module/Removeaccount.php @@ -29,7 +29,7 @@ class Removeaccount extends \Zotlabs\Web\Controller { if(! ($x && $x['account'])) return; - if($account['account_password_changed'] != NULL_DATE) { + if($account['account_password_changed'] > NULL_DATE) { $d1 = datetime_convert('UTC','UTC','now - 48 hours'); if($account['account_password_changed'] > d1) { notice( t('Account removals are not allowed within 48 hours of changing the account password.') . EOL); diff --git a/Zotlabs/Module/Removeme.php b/Zotlabs/Module/Removeme.php index bc18fe0f8..ca2080e83 100644 --- a/Zotlabs/Module/Removeme.php +++ b/Zotlabs/Module/Removeme.php @@ -29,7 +29,7 @@ class Removeme extends \Zotlabs\Web\Controller { if(! ($x && $x['account'])) return; - if($account['account_password_changed'] != NULL_DATE) { + if($account['account_password_changed'] > NULL_DATE) { $d1 = datetime_convert('UTC','UTC','now - 48 hours'); if($account['account_password_changed'] > d1) { notice( t('Channel removals are not allowed within 48 hours of changing the account password.') . EOL); diff --git a/Zotlabs/Module/Settings/Tokens.php b/Zotlabs/Module/Settings/Tokens.php index 0ae960785..e63fed128 100644 --- a/Zotlabs/Module/Settings/Tokens.php +++ b/Zotlabs/Module/Settings/Tokens.php @@ -156,7 +156,7 @@ class Tokens { '$url2' => z_root() . '/photos/' . $channel['channel_address'], '$name' => array('name', t('Login Name') . ' *', (($atoken) ? $atoken['atoken_name'] : ''),''), '$token'=> array('token', t('Login Password') . ' *',(($atoken) ? $atoken['atoken_token'] : autoname(8)), ''), - '$expires'=> array('expires', t('Expires (yyyy-mm-dd)'), (($atoken['atoken_expires'] && $atoken['atoken_expires'] != NULL_DATE) ? datetime_convert('UTC',date_default_timezone_get(),$atoken['atoken_expires']) : ''), ''), + '$expires'=> array('expires', t('Expires (yyyy-mm-dd)'), (($atoken['atoken_expires'] && $atoken['atoken_expires'] > NULL_DATE) ? datetime_convert('UTC',date_default_timezone_get(),$atoken['atoken_expires']) : ''), ''), '$them' => t('Their Settings'), '$me' => t('My Settings'), '$perms' => $perms, diff --git a/include/account.php b/include/account.php index 47310912f..bd4da6a52 100644 --- a/include/account.php +++ b/include/account.php @@ -548,8 +548,8 @@ function account_approve($hash) { */ function downgrade_accounts() { - $r = q("select * from account where not ( account_flags & %d )>0 - and account_expires != '%s' + $r = q("select * from account where not ( account_flags & %d ) > 0 + and account_expires > '%s' and account_expires < %s ", intval(ACCOUNT_EXPIRED), dbesc(NULL_DATE), diff --git a/include/channel.php b/include/channel.php index 5beb4a53c..c86cea6f1 100644 --- a/include/channel.php +++ b/include/channel.php @@ -1212,7 +1212,7 @@ function advanced_profile(&$a) { if(App::$profile['partner']) $profile['marital']['partner'] = bbcode(App::$profile['partner']); - if(strlen(App::$profile['howlong']) && App::$profile['howlong'] !== NULL_DATE) { + if(strlen(App::$profile['howlong']) && App::$profile['howlong'] > NULL_DATE) { $profile['howlong'] = relative_date(App::$profile['howlong'], t('for %1$d %2$s')); } diff --git a/include/conversation.php b/include/conversation.php index e515fb26a..62b22e893 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -723,7 +723,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'), 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), 'editedtime' => (($item['edited'] != $item['created']) ? sprintf( t('last edited: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r')) : ''), - 'expiretime' => (($item['expires'] !== NULL_DATE) ? sprintf( t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r')):''), + 'expiretime' => (($item['expires'] > NULL_DATE) ? sprintf( t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r')):''), 'location' => $location, 'indent' => '', 'owner_name' => $owner_name, diff --git a/include/datetime.php b/include/datetime.php index 914eac95e..c72e4bf83 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -275,7 +275,7 @@ function relative_date($posted_date, $format = null) { $abs = strtotime($localtime); - if (is_null($posted_date) || $posted_date === NULL_DATE || $abs === false) { + if (is_null($posted_date) || is_null_date($posted_date) || $abs === false) { return t('never'); } diff --git a/include/dir_fns.php b/include/dir_fns.php index 53a81b242..03cc2706a 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -227,7 +227,7 @@ function sync_directories($dirmode) { $token = get_config('system','realm_token'); - $syncdate = (($rr['site_sync'] === NULL_DATE) ? datetime_convert('UTC','UTC','now - 2 days') : $rr['site_sync']); + $syncdate = (($rr['site_sync'] <= NULL_DATE) ? datetime_convert('UTC','UTC','now - 2 days') : $rr['site_sync']); $x = z_fetch_url($rr['site_directory'] . '?f=&sync=' . urlencode($syncdate) . (($token) ? '&t=' . $token : '')); if (! $x['success']) diff --git a/include/feedutils.php b/include/feedutils.php index 01ec0687e..1d58ec317 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -33,7 +33,7 @@ function get_public_feed($channel, $params) { // put a sane lower limit on feed requests if not specified -// if($params['begin'] === NULL_DATE) +// if($params['begin'] <= NULL_DATE) // $params['begin'] = datetime_convert('UTC','UTC','now - 1 month'); switch($params['type']) { @@ -884,7 +884,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { $datarray['owner_xchan'] = $contact['xchan_hash']; - if(array_key_exists('created',$datarray) && $datarray['created'] != NULL_DATE && $expire_days) { + if(array_key_exists('created',$datarray) && $datarray['created'] > NULL_DATE && $expire_days) { $t1 = $datarray['created']; $t2 = datetime_convert('UTC','UTC','now - ' . $expire_days . 'days'); if($t1 < $t2) { diff --git a/include/import.php b/include/import.php index ddffb2ac3..3b434c935 100644 --- a/include/import.php +++ b/include/import.php @@ -422,9 +422,9 @@ function sync_apps($channel,$apps) { ); } - if(! $app['app_created'] || $app['app_created'] === NULL_DATE) + if((! $app['app_created']) || ($app['app_created'] <= NULL_DATE)) $app['app_created'] = datetime_convert(); - if(! $app['app_edited'] || $app['app_edited'] === NULL_DATE) + if((! $app['app_edited']) || ($app['app_edited'] <= NULL_DATE)) $app['app_edited'] = datetime_convert(); $app['app_channel'] = $channel['channel_id']; @@ -536,9 +536,9 @@ function sync_chatrooms($channel,$chatrooms) { unset($chatroom['cr_aid']); unset($chatroom['cr_uid']); - if(! $chatroom['cr_created'] || $chatroom['cr_created'] === NULL_DATE) + if((! $chatroom['cr_created']) || ($chatroom['cr_created'] <= NULL_DATE)) $chatroom['cr_created'] = datetime_convert(); - if(! $chatroom['cr_edited'] || $chatroom['cr_edited'] === NULL_DATE) + if((! $chatroom['cr_edited']) || ($chatroom['cr_edited'] <= NULL_DATE)) $chatroom['cr_edited'] = datetime_convert(); $chatroom['cr_aid'] = $channel['channel_account_id']; diff --git a/include/items.php b/include/items.php index ba39fd7ac..fd9fc05ff 100755 --- a/include/items.php +++ b/include/items.php @@ -163,7 +163,7 @@ function collect_recipients($item, &$private_envelope) { } function comments_are_now_closed($item) { - if($item['comments_closed'] !== NULL_DATE) { + if($item['comments_closed'] > NULL_DATE) { $d = datetime_convert(); if($d > $item['comments_closed']) return true; @@ -1090,7 +1090,7 @@ function encode_item($item,$mirror = false) { if($y = encode_item_flags($item)) $x['flags'] = $y; - if($item['comments_closed'] !== NULL_DATE) + if($item['comments_closed'] > NULL_DATE) $x['comments_closed'] = $item['comments_closed']; $x['public_scope'] = $scope; @@ -1439,7 +1439,7 @@ function get_mail_elements($x) { $arr['conv_guid'] = (($x['conv_guid'])? htmlspecialchars($x['conv_guid'],ENT_COMPAT,'UTF-8',false) : ''); $arr['created'] = datetime_convert('UTC','UTC',$x['created']); - if((! array_key_exists('expires',$x)) || ($x['expires'] === NULL_DATE)) + if((! array_key_exists('expires',$x)) || ($x['expires'] <= NULL_DATE)) $arr['expires'] = NULL_DATE; else $arr['expires'] = datetime_convert('UTC','UTC',$x['expires']); @@ -2062,7 +2062,7 @@ function item_store_update($arr,$allow_exec = false, $deliver = true) { $arr['edited'] = ((x($arr,'edited') !== false) ? datetime_convert('UTC','UTC',$arr['edited']) : datetime_convert()); $arr['expires'] = ((x($arr,'expires') !== false) ? datetime_convert('UTC','UTC',$arr['expires']) : $orig[0]['expires']); - if(array_key_exists('comments_closed',$arr) && $arr['comments_closed'] != NULL_DATE) + if(array_key_exists('comments_closed',$arr) && $arr['comments_closed'] > NULL_DATE) $arr['comments_closed'] = datetime_convert('UTC','UTC',$arr['comments_closed']); else $arr['comments_closed'] = $orig[0]['comments_closed']; @@ -3829,7 +3829,7 @@ function zot_feed($uid,$observer_hash,$arr) { $limit = " LIMIT 100 "; - if($mindate != NULL_DATE) { + if($mindate > NULL_DATE) { $sql_extra .= " and ( created > '$mindate' or changed > '$mindate' ) "; } -- cgit v1.2.3