diff --git a/include/api.php b/include/api.php index 7044524a76..d20cd03dec 100644 --- a/include/api.php +++ b/include/api.php @@ -460,7 +460,7 @@ function api_rss_extra(App $a, $arr, $user_info) 'self' => System::baseUrl() . "/" . $a->query_string, 'base' => System::baseUrl(), 'updated' => api_date(null), - 'atom_updated' => Temporal::convert('now', 'UTC', 'UTC', Temporal::ATOM), + 'atom_updated' => Temporal::utcNow(Temporal::ATOM), 'language' => $user_info['language'], 'logo' => System::baseUrl() . "/images/friendica-32.png", ]; @@ -4216,7 +4216,7 @@ function api_fr_photo_create_update($type) $result = q( "UPDATE `photo` SET %s, `edited`='%s' WHERE `uid` = %d AND `resource-id` = '%s' AND `album` = '%s'", $sql_extra, - Temporal::convert(), // update edited timestamp + Temporal::utcNow(), // update edited timestamp intval(api_user()), dbesc($photo_id), dbesc($album) @@ -4420,7 +4420,7 @@ function api_account_update_profile_image($type) q( "UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d", - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval(local_user()) ); diff --git a/include/dba.php b/include/dba.php index e7a5db1afb..180748db96 100644 --- a/include/dba.php +++ b/include/dba.php @@ -190,7 +190,7 @@ class dba { if ($log) { $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - @file_put_contents($a->config["system"]["db_log_index"], Temporal::convert()."\t". + @file_put_contents($a->config["system"]["db_log_index"], Temporal::utcNow()."\t". $row['key']."\t".$row['rows']."\t".$row['Extra']."\t". basename($backtrace[1]["file"])."\t". $backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t". @@ -495,7 +495,7 @@ class dba { $duration = round($duration, 3); $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - @file_put_contents($a->config["system"]["db_log"], Temporal::convert()."\t".$duration."\t". + @file_put_contents($a->config["system"]["db_log"], Temporal::utcNow()."\t".$duration."\t". basename($backtrace[1]["file"])."\t". $backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t". substr(self::replace_parameters($sql, $args), 0, 2000)."\n", FILE_APPEND); diff --git a/include/enotify.php b/include/enotify.php index 6b2f5e6ef9..cf219676ec 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -451,7 +451,7 @@ function notification($params) $datarray['name_cache'] = strip_tags(bbcode($params['source_name'])); $datarray['url'] = $params['source_link']; $datarray['photo'] = $params['source_photo']; - $datarray['date'] = Temporal::convert(); + $datarray['date'] = Temporal::utcNow(); $datarray['uid'] = $params['uid']; $datarray['link'] = $itemlink; $datarray['iid'] = $item_id; diff --git a/include/event.php b/include/event.php index 59ac8d4a2c..c69bd50e07 100644 --- a/include/event.php +++ b/include/event.php @@ -240,8 +240,8 @@ function event_store($arr) { $a = get_app(); - $arr['created'] = (($arr['created']) ? $arr['created'] : Temporal::convert()); - $arr['edited'] = (($arr['edited']) ? $arr['edited'] : Temporal::convert()); + $arr['created'] = (($arr['created']) ? $arr['created'] : Temporal::utcNow()); + $arr['edited'] = (($arr['edited']) ? $arr['edited'] : Temporal::utcNow()); $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); $arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0); $arr['uri'] = (x($arr, 'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(), $arr['uid'])); diff --git a/include/security.php b/include/security.php index 9b14ed3415..e370e9340c 100644 --- a/include/security.php +++ b/include/security.php @@ -142,10 +142,10 @@ function authenticate_success($user_record, $login_initial = false, $interactive header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] . '"'); if ($login_initial || $login_refresh) { - dba::update('user', ['login_date' => Temporal::convert()], ['uid' => $_SESSION['uid']]); + dba::update('user', ['login_date' => Temporal::utcNow()], ['uid' => $_SESSION['uid']]); // Set the login date for all identities of the user - dba::update('user', ['login_date' => Temporal::convert()], + dba::update('user', ['login_date' => Temporal::utcNow()], ['password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false]); } diff --git a/include/text.php b/include/text.php index def479ce33..6a48d7ef83 100644 --- a/include/text.php +++ b/include/text.php @@ -723,7 +723,7 @@ function logger($msg, $level = 0) { $callers = debug_backtrace(); $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n", - Temporal::convert('now', 'UTC', 'UTC', Temporal::ATOM), + Temporal::utcNow(Temporal::ATOM), $process_id, $LOGGER_LEVELS[$level], basename($callers[0]['file']), @@ -789,7 +789,7 @@ function dlogger($msg, $level = 0) { $callers = debug_backtrace(); $logline = sprintf("%s@\t%s:\t%s:\t%s\t%s\t%s\n", - Temporal::convert(), + Temporal::utcNow(), $process_id, basename($callers[0]['file']), $callers[0]['line'], diff --git a/mod/admin.php b/mod/admin.php index 9ce4f8d65d..9bd94cd03d 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -740,7 +740,7 @@ function admin_page_summary(App $a) if (!$last_worker_call) { $showwarning = true; $warningtext[] = L10n::t('The worker was never executed. Please check your database structure!'); - } elseif ((strtotime(Temporal::convert()) - strtotime($last_worker_call)) > 60 * 60) { + } elseif ((strtotime(Temporal::utcNow()) - strtotime($last_worker_call)) > 60 * 60) { $showwarning = true; $warningtext[] = L10n::t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.', $last_worker_call); } diff --git a/mod/contacts.php b/mod/contacts.php index 43e6ae826d..6bd6f753ff 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -554,7 +554,7 @@ function contacts_content(App $a) // tabs $tab_str = contacts_tab($a, $contact_id, 2); - $lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < datetime_convert('', '', 'now')) ? L10n::t('Communications lost with this contact!') : ''); + $lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < Temporal::utcNow()) ? L10n::t('Communications lost with this contact!') : ''); $fetch_further_information = null; if ($contact['network'] == NETWORK_FEED) { diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 95a928c373..9a46d463b7 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -327,8 +327,8 @@ function dfrn_confirm_post(App $a, $handsfree = null) `network` = '%s' WHERE `id` = %d ", intval($new_relation), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), intval($duplex), intval($hidden), dbesc(NETWORK_DFRN), @@ -378,8 +378,8 @@ function dfrn_confirm_post(App $a, $handsfree = null) `rel` = %d WHERE `id` = %d ", - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), dbesc($addr), dbesc($notify), dbesc($poll), @@ -619,8 +619,8 @@ function dfrn_confirm_post(App $a, $handsfree = null) `network` = '%s' WHERE `id` = %d ", intval($new_relation), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), intval($duplex), intval($forum), intval($prv), diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 06b2e6b778..161cd4b1bd 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -137,7 +137,7 @@ function dfrn_request_post(App $a) `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`, `blocked`, `pending`) VALUES ( %d, '%s', '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d)", intval(local_user()), - Temporal::convert(), + Temporal::utcNow(), dbesc($dfrn_url), dbesc(normalise_link($dfrn_url)), $parms['addr'], @@ -382,7 +382,7 @@ function dfrn_request_post(App $a) `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `blocked`, `pending` ) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )", intval($uid), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), $parms['url'], dbesc(normalise_link($url)), $parms['addr'], @@ -430,7 +430,7 @@ function dfrn_request_post(App $a) ((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0), dbesc(notags(trim($_POST['dfrn-request-message']))), dbesc($hash), - dbesc(Temporal::convert()) + dbesc(Temporal::utcNow()) ); } diff --git a/mod/fsuggest.php b/mod/fsuggest.php index 92c41661f2..ccd38217d2 100644 --- a/mod/fsuggest.php +++ b/mod/fsuggest.php @@ -52,7 +52,7 @@ function fsuggest_post(App $a) dbesc($r[0]['request']), dbesc($r[0]['photo']), dbesc($hash), - dbesc(Temporal::convert()) + dbesc(Temporal::utcNow()) ); $r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1", dbesc($hash), diff --git a/mod/invite.php b/mod/invite.php index 3b3b94c3d1..8ecbbe6cd8 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -62,7 +62,7 @@ function invite_post(App $a) $r = q("INSERT INTO `register` (`hash`,`created`) VALUES ('%s', '%s') ", dbesc($code), - dbesc(Temporal::convert()) + dbesc(Temporal::utcNow()) ); if (! is_site_admin()) { diff --git a/mod/item.php b/mod/item.php index 7a5a8aab48..1b00102816 100644 --- a/mod/item.php +++ b/mod/item.php @@ -601,11 +601,11 @@ function item_post(App $a) { $datarray['author-link'] = $author['url']; $datarray['author-avatar'] = $author['thumb']; $datarray['author-id'] = Contact::getIdForURL($datarray['author-link'], 0); - $datarray['created'] = Temporal::convert(); - $datarray['edited'] = Temporal::convert(); - $datarray['commented'] = Temporal::convert(); - $datarray['received'] = Temporal::convert(); - $datarray['changed'] = Temporal::convert(); + $datarray['created'] = Temporal::utcNow(); + $datarray['edited'] = Temporal::utcNow(); + $datarray['commented'] = Temporal::utcNow(); + $datarray['received'] = Temporal::utcNow(); + $datarray['changed'] = Temporal::utcNow(); $datarray['extid'] = $extid; $datarray['guid'] = $guid; $datarray['uri'] = $uri; @@ -709,8 +709,8 @@ function item_post(App $a) { 'file' => $datarray['file'], 'rendered-html' => $datarray['rendered-html'], 'rendered-hash' => $datarray['rendered-hash'], - 'edited' => Temporal::convert(), - 'changed' => Temporal::convert()]; + 'edited' => Temporal::utcNow(), + 'changed' => Temporal::utcNow()]; Item::update($fields, ['id' => $post_id]); diff --git a/mod/lostpass.php b/mod/lostpass.php index 87e492a92a..a34562de7d 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -33,7 +33,7 @@ function lostpass_post(App $a) $fields = [ 'pwdreset' => $pwdreset_token, - 'pwdreset_time' => Temporal::convert() + 'pwdreset_time' => Temporal::utcNow() ]; $result = dba::update('user', $fields, ['uid' => $user['uid']]); if ($result) { diff --git a/mod/network.php b/mod/network.php index b5f58be40b..01b6413e6a 100644 --- a/mod/network.php +++ b/mod/network.php @@ -790,8 +790,8 @@ function networkThreadedView(App $a, $update = 0) $top_limit = current($r)['order_date']; $bottom_limit = end($r)['order_date']; } else { - $top_limit = Temporal::convert(); - $bottom_limit = Temporal::convert(); + $top_limit = Temporal::utcNow(); + $bottom_limit = Temporal::utcNow(); } // When checking for updates we need to fetch from the newest date to the newest date before @@ -804,7 +804,7 @@ function networkThreadedView(App $a, $update = 0) $top_limit = $last_date; } elseif ($a->pager['page'] == 1) { // Highest possible top limit when we are on the first page - $top_limit = Temporal::convert(); + $top_limit = Temporal::utcNow(); } $items = dba::p("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM `item` diff --git a/mod/photos.php b/mod/photos.php index 2a1e7a4cdc..a7ed50a44c 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -291,7 +291,7 @@ function photos_post(App $a) if (DBM::is_result($r)) { foreach ($r as $rr) { q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), dbesc($rr['parent-uri']), intval($page_owner_uid) ); @@ -364,8 +364,8 @@ function photos_post(App $a) ); if (DBM::is_result($i)) { q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), dbesc($i[0]['uri']), intval($page_owner_uid) ); @@ -649,8 +649,8 @@ function photos_post(App $a) $r = q("UPDATE `item` SET `tag` = '%s', `inform` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d", dbesc($newtag), dbesc($newinform), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), intval($item_id), intval($page_owner_uid) ); @@ -1361,7 +1361,7 @@ function photos_content(App $a) $photo = [ 'href' => 'photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']], 'title'=> L10n::t('View Full Size'), - 'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . Temporal::convert('now', 'UTC', 'UTC', 'ymdhis'), + 'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . Temporal::utcNow('ymdhis'), 'height' => $hires['height'], 'width' => $hires['width'], 'album' => $hires['album'], diff --git a/mod/ping.php b/mod/ping.php index 2bbe87254e..9d5a6c4096 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -226,7 +226,7 @@ function ping_init(App $a) ORDER BY `start` ASC ", intval(local_user()), dbesc(Temporal::convert('now + 7 days')), - dbesc(Temporal::convert('now')) + dbesc(Temporal::utcNow()) ); if (DBM::is_result($ev)) { Cache::set($cachekey, $ev, CACHE_HOUR); diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 8c3c0de893..82050e962e 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -130,7 +130,7 @@ function profile_photo_post(App $a) { // so that browsers will do a cache update unconditionally $r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d", - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval(local_user()) ); @@ -230,7 +230,7 @@ function profile_photo_content(App $a) { ); $r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d", - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval(local_user()) ); diff --git a/mod/profiles.php b/mod/profiles.php index 5c4a14dd6b..6206fdae3d 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -487,7 +487,7 @@ function profiles_post(App $a) { if ($namechanged && $is_default) { $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d", dbesc($name), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval(local_user()) ); $r = q("UPDATE `user` set `username` = '%s' where `uid` = %d", diff --git a/mod/proxy.php b/mod/proxy.php index 244a6cae23..332b5bd1b0 100644 --- a/mod/proxy.php +++ b/mod/proxy.php @@ -188,7 +188,7 @@ function proxy_init(App $a) { die(); } - $fields = ['uid' => 0, 'contact-id' => 0, 'guid' => get_guid(), 'resource-id' => $urlhash, 'created' => Temporal::convert(), 'edited' => Temporal::convert(), + $fields = ['uid' => 0, 'contact-id' => 0, 'guid' => get_guid(), 'resource-id' => $urlhash, 'created' => Temporal::utcNow(), 'edited' => Temporal::utcNow(), 'filename' => basename($_REQUEST['url']), 'type' => '', 'album' => '', 'height' => imagesy($image), 'width' => imagesx($image), 'datasize' => 0, 'data' => $img_str, 'scale' => 100, 'profile' => 0, 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'desc' => $mime]; diff --git a/mod/pubsubhubbub.php b/mod/pubsubhubbub.php index ffab754dee..4dc163cbad 100644 --- a/mod/pubsubhubbub.php +++ b/mod/pubsubhubbub.php @@ -139,7 +139,7 @@ function pubsubhubbub_init(App $a) { dbesc($hub_callback)); if ($subscribe) { - $last_update = Temporal::convert(); + $last_update = Temporal::utcNow(); $push_flag = 0; // if we are just updating an old subscription, keep the diff --git a/mod/register.php b/mod/register.php index f0ed5cd4a5..07a20e318d 100644 --- a/mod/register.php +++ b/mod/register.php @@ -118,7 +118,7 @@ function register_post(App $a) $hash = random_string(); $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language`, `note` ) VALUES ( '%s', '%s', %d, '%s', '%s', '%s' ) ", dbesc($hash), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval($user['uid']), dbesc($result['password']), dbesc($lang), diff --git a/mod/settings.php b/mod/settings.php index 3603008bf5..5c220cb35a 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -631,7 +631,7 @@ function settings_post(App $a) if ($name_change) { q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self`", dbesc($username), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval(local_user()) ); } diff --git a/mod/videos.php b/mod/videos.php index 00fa885987..66ca2979fc 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -170,8 +170,8 @@ function videos_post(App $a) { //echo "
"; var_dump($i); killme(); if (DBM::is_result($i)) { q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), dbesc($i[0]['uri']), intval(local_user()) ); diff --git a/mod/wall_attach.php b/mod/wall_attach.php index 1ad435c45d..8cdee398e8 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -124,7 +124,7 @@ function wall_attach_post(App $a) { $filedata = @file_get_contents($src); $mimetype = Mimetype::getContentType($filename); $hash = get_guid(64); - $created = Temporal::convert(); + $created = Temporal::utcNow(); $fields = ['uid' => $page_owner_uid, 'hash' => $hash, 'filename' => $filename, 'filetype' => $mimetype, 'filesize' => $filesize, 'data' => $filedata, 'created' => $created, 'edited' => $created, diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index 4ff353fa94..2a9db64882 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -113,7 +113,7 @@ class OEmbed 'url' => normalise_link($embedurl), 'maxwidth' => $a->videowidth, 'content' => $txt, - 'created' => Temporal::convert() + 'created' => Temporal::utcNow() ], true); } diff --git a/src/Core/Cache.php b/src/Core/Cache.php index c6368219a1..f77319a46a 100644 --- a/src/Core/Cache.php +++ b/src/Core/Cache.php @@ -147,7 +147,7 @@ class Cache $memcache->set(get_app()->get_hostname().":".$key, serialize($value), MEMCACHE_COMPRESSED, self::duration($duration)); return; } - $fields = ['v' => serialize($value), 'expire_mode' => $duration, 'updated' => Temporal::convert()]; + $fields = ['v' => serialize($value), 'expire_mode' => $duration, 'updated' => Temporal::utcNow()]; $condition = ['k' => $key]; dba::update('cache', $fields, $condition, true); } diff --git a/src/Core/Worker.php b/src/Core/Worker.php index cb1877dbcc..8ff37c0195 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -235,7 +235,7 @@ class Worker if ($age > 1) { $stamp = (float)microtime(true); - dba::update('workerqueue', ['executed' => Temporal::convert()], ['pid' => $mypid, 'done' => false]); + dba::update('workerqueue', ['executed' => Temporal::utcNow()], ['pid' => $mypid, 'done' => false]); self::$db_duration += (microtime(true) - $stamp); } @@ -245,7 +245,7 @@ class Worker $stamp = (float)microtime(true); if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) { - Config::set('system', 'last_poller_execution', Temporal::convert()); + Config::set('system', 'last_poller_execution', Temporal::utcNow()); } self::$db_duration = (microtime(true) - $stamp); @@ -278,7 +278,7 @@ class Worker if ($age > 1) { $stamp = (float)microtime(true); - dba::update('workerqueue', ['executed' => Temporal::convert()], ['pid' => $mypid, 'done' => false]); + dba::update('workerqueue', ['executed' => Temporal::utcNow()], ['pid' => $mypid, 'done' => false]); self::$db_duration += (microtime(true) - $stamp); } @@ -286,7 +286,7 @@ class Worker $stamp = (float)microtime(true); if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) { - Config::set('system', 'last_poller_execution', Temporal::convert()); + Config::set('system', 'last_poller_execution', Temporal::utcNow()); } self::$db_duration = (microtime(true) - $stamp); } else { @@ -574,7 +574,7 @@ class Worker } dba::update( 'workerqueue', - ['executed' => NULL_DATE, 'created' => Temporal::convert(), 'priority' => $new_priority, 'pid' => 0], + ['executed' => NULL_DATE, 'created' => Temporal::utcNow(), 'priority' => $new_priority, 'pid' => 0], ['id' => $entry["id"]] ); } else { @@ -825,7 +825,7 @@ class Worker if ($found) { $condition = "`id` IN (".substr(str_repeat("?, ", count($ids)), 0, -2).") AND `pid` = 0 AND NOT `done`"; array_unshift($ids, $condition); - dba::update('workerqueue', ['executed' => Temporal::convert(), 'pid' => $mypid], $ids); + dba::update('workerqueue', ['executed' => Temporal::utcNow(), 'pid' => $mypid], $ids); } return $found; @@ -1040,7 +1040,7 @@ class Worker $priority = PRIORITY_MEDIUM; $dont_fork = Config::get("system", "worker_dont_fork"); - $created = Temporal::convert(); + $created = Temporal::utcNow(); if (is_int($run_parameter)) { $priority = $run_parameter; diff --git a/src/Database/DBM.php b/src/Database/DBM.php index 8a57d04a60..ffe8785f10 100644 --- a/src/Database/DBM.php +++ b/src/Database/DBM.php @@ -126,6 +126,6 @@ class DBM $timestamp = -62135596800; } - return date('Y-m-d H:i:s', (int)$timestamp); + return date(Temporal::MYSQL, (int)$timestamp); } } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index c3e154d7e8..5afeebad4c 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -112,7 +112,7 @@ class Contact extends BaseObject $return = dba::insert('contact', [ 'uid' => $user['uid'], - 'created' => Temporal::convert(), + 'created' => Temporal::utcNow(), 'self' => 1, 'name' => $user['username'], 'nick' => $user['nickname'], @@ -129,9 +129,9 @@ class Contact extends BaseObject 'poll' => System::baseUrl() . '/dfrn_poll/' . $user['nickname'], 'confirm' => System::baseUrl() . '/dfrn_confirm/' . $user['nickname'], 'poco' => System::baseUrl() . '/poco/' . $user['nickname'], - 'name-date' => Temporal::convert(), - 'uri-date' => Temporal::convert(), - 'avatar-date' => Temporal::convert(), + 'name-date' => Temporal::utcNow(), + 'uri-date' => Temporal::utcNow(), + 'avatar-date' => Temporal::utcNow(), 'closeness' => 0 ]); @@ -210,10 +210,10 @@ class Contact extends BaseObject } if ($contact['term-date'] <= NULL_DATE) { - dba::update('contact', ['term-date' => Temporal::convert()], ['id' => $contact['id']]); + dba::update('contact', ['term-date' => Temporal::utcNow()], ['id' => $contact['id']]); if ($contact['url'] != '') { - dba::update('contact', ['term-date' => Temporal::convert()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]); + dba::update('contact', ['term-date' => Temporal::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]); } } else { /* @todo @@ -224,7 +224,7 @@ class Contact extends BaseObject /// @todo Check for contact vitality via probing $expiry = $contact['term-date'] . ' + 32 days '; - if (Temporal::convert() > Temporal::convert($expiry)) { + if (Temporal::utcNow() > Temporal::convert($expiry)) { /* Relationship is really truly dead. archive them rather than * delete, though if the owner tries to unarchive them we'll start * the whole process over again. @@ -728,7 +728,7 @@ class Contact extends BaseObject if (!$contact_id) { dba::insert('contact', [ 'uid' => $uid, - 'created' => Temporal::convert(), + 'created' => Temporal::utcNow(), 'url' => $data["url"], 'nurl' => normalise_link($data["url"]), 'addr' => $data["addr"], @@ -749,9 +749,9 @@ class Contact extends BaseObject 'request' => $data["request"], 'confirm' => $data["confirm"], 'poco' => $data["poco"], - 'name-date' => Temporal::convert(), - 'uri-date' => Temporal::convert(), - 'avatar-date' => Temporal::convert(), + 'name-date' => Temporal::utcNow(), + 'uri-date' => Temporal::utcNow(), + 'avatar-date' => Temporal::utcNow(), 'writable' => 1, 'blocked' => 0, 'readonly' => 0, @@ -823,13 +823,13 @@ class Contact extends BaseObject } if (($data["addr"] != $contact["addr"]) || ($data["alias"] != $contact["alias"])) { - $updated['uri-date'] = Temporal::convert(); + $updated['uri-date'] = Temporal::utcNow(); } if (($data["name"] != $contact["name"]) || ($data["nick"] != $contact["nick"])) { - $updated['name-date'] = Temporal::convert(); + $updated['name-date'] = Temporal::utcNow(); } - $updated['avatar-date'] = Temporal::convert(); + $updated['avatar-date'] = Temporal::utcNow(); dba::update('contact', $updated, ['id' => $contact_id], $contact); @@ -1026,7 +1026,7 @@ class Contact extends BaseObject if ($photos) { dba::update( 'contact', - ['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => Temporal::convert()], + ['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => Temporal::utcNow()], ['id' => $cid] ); @@ -1261,7 +1261,7 @@ class Contact extends BaseObject // create contact record dba::insert('contact', [ 'uid' => $uid, - 'created' => Temporal::convert(), + 'created' => Temporal::utcNow(), 'url' => $ret['url'], 'nurl' => normalise_link($ret['url']), 'addr' => $ret['addr'], @@ -1485,7 +1485,7 @@ class Contact extends BaseObject foreach ($r as $rr) { logger('update_contact_birthday: ' . $rr['bd']); - $nextbd = Temporal::convert('now', 'UTC', 'UTC', 'Y') . substr($rr['bd'], 4); + $nextbd = Temporal::convert('Y') . substr($rr['bd'], 4); /* * Add new birthday event for this person @@ -1508,7 +1508,7 @@ class Contact extends BaseObject q("INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`summary`,`desc`,`type`,`adjust`) VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d' ) ", intval($rr['uid']), intval($rr['id']), - dbesc(Temporal::convert()), dbesc(Temporal::convert()), dbesc(Temporal::convert($nextbd)), + dbesc(Temporal::utcNow()), dbesc(Temporal::utcNow()), dbesc(Temporal::convert($nextbd)), dbesc(Temporal::convert($nextbd . ' + 1 day ')), dbesc($bdtext), dbesc($bdtext2), dbesc('birthday'), intval(0) ); diff --git a/src/Model/GContact.php b/src/Model/GContact.php index 1e0adac494..f588ec62b2 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -120,12 +120,12 @@ class GContact intval($uid), intval($gcid), intval($zcid), - dbesc(Temporal::convert()) + dbesc(Temporal::utcNow()) ); } else { q( "UPDATE `glink` SET `updated` = '%s' WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d", - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval($cid), intval($uid), intval($gcid), @@ -717,8 +717,8 @@ class GContact dbesc($contact["url"]), dbesc(normalise_link($contact["url"])), dbesc($contact["photo"]), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), dbesc($contact["location"]), dbesc($contact["about"]), intval($contact["hide"]), @@ -1050,7 +1050,7 @@ class GContact foreach ($r as $server) { self::fetchGsUsers($server["url"]); - q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(Temporal::convert()), dbesc($server["nurl"])); + q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(Temporal::utcNow()), dbesc($server["nurl"])); } } diff --git a/src/Model/Item.php b/src/Model/Item.php index 8628ac42d9..62f19aeb5a 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -149,7 +149,7 @@ class Item extends BaseObject // Set the item to "deleted" dba::update('item', ['deleted' => true, 'title' => '', 'body' => '', - 'edited' => Temporal::convert(), 'changed' => Temporal::convert()], + 'edited' => Temporal::utcNow(), 'changed' => Temporal::utcNow()], ['id' => $item['id']]); create_tags_from_item($item['id']); diff --git a/src/Model/Mail.php b/src/Model/Mail.php index 701cf3ad95..41981fe9e2 100644 --- a/src/Model/Mail.php +++ b/src/Model/Mail.php @@ -82,7 +82,7 @@ class Mail $handles = $recip_handle . ';' . $sender_handle; $fields = ['uid' => local_user(), 'guid' => $conv_guid, 'creator' => $sender_handle, - 'created' => Temporal::convert(), 'updated' => Temporal::convert(), + 'created' => Temporal::utcNow(), 'updated' => Temporal::utcNow(), 'subject' => $subject, 'recips' => $handles]; if (dba::insert('conv', $fields)) { $convid = dba::lastInsertId(); @@ -116,7 +116,7 @@ class Mail 'replied' => 0, 'uri' => $uri, 'parent-uri' => $replyto, - 'created' => Temporal::convert() + 'created' => Temporal::utcNow() ] ); @@ -196,7 +196,7 @@ class Mail $convid = null; $fields = ['uid' => $recipient['uid'], 'guid' => $conv_guid, 'creator' => $sender_handle, - 'created' => Temporal::convert(), 'updated' => Temporal::convert(), + 'created' => Temporal::utcNow(), 'updated' => Temporal::utcNow(), 'subject' => $subject, 'recips' => $handles]; if (dba::insert('conv', $fields)) { $convid = dba::lastInsertId(); @@ -224,7 +224,7 @@ class Mail 'replied' => 0, 'uri' => $uri, 'parent-uri' => $replyto, - 'created' => Temporal::convert(), + 'created' => Temporal::utcNow(), 'unknown' => 1 ] ); diff --git a/src/Model/Photo.php b/src/Model/Photo.php index a2c69f994c..a736c36386 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -55,8 +55,8 @@ class Photo 'contact-id' => $cid, 'guid' => $guid, 'resource-id' => $rid, - 'created' => Temporal::convert(), - 'edited' => Temporal::convert(), + 'created' => Temporal::utcNow(), + 'edited' => Temporal::utcNow(), 'filename' => basename($filename), 'type' => $Image->getType(), 'album' => $album, diff --git a/src/Model/Process.php b/src/Model/Process.php index 99d5af543b..5cb3369c66 100644 --- a/src/Model/Process.php +++ b/src/Model/Process.php @@ -34,7 +34,7 @@ class Process extends BaseObject dba::transaction(); if (!dba::exists('process', ['pid' => $pid])) { - $return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => Temporal::convert()]); + $return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => Temporal::utcNow()]); } dba::commit(); diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 665945032a..bdc64a8ac2 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -557,7 +557,7 @@ class Profile ORDER BY `start` ASC ", local_user(), Temporal::convert('now + 6 days'), - Temporal::convert('now') + Temporal::utcNow() ); if (DBM::is_result($s)) { $r = dba::inArray($s); diff --git a/src/Model/Queue.php b/src/Model/Queue.php index 99ba6385c1..6c49ff4d1a 100644 --- a/src/Model/Queue.php +++ b/src/Model/Queue.php @@ -20,7 +20,7 @@ class Queue public static function updateTime($id) { logger('queue: requeue item ' . $id); - dba::update('queue', ['last' => Temporal::convert()], ['id' => $id]); + dba::update('queue', ['last' => Temporal::utcNow()], ['id' => $id]); } /** @@ -95,6 +95,6 @@ class Queue } } - dba::insert('queue', ['cid' => $cid, 'network' => $network, 'created' => Temporal::convert(), 'last' => Temporal::convert(), 'content' => $msg, 'batch' =>($batch) ? 1 : 0]); + dba::insert('queue', ['cid' => $cid, 'network' => $network, 'created' => Temporal::utcNow(), 'last' => Temporal::utcNow(), 'content' => $msg, 'batch' =>($batch) ? 1 : 0]); } } diff --git a/src/Model/User.php b/src/Model/User.php index 618c5988f1..3ef2a45955 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -396,7 +396,7 @@ class User 'verified' => $verified, 'blocked' => $blocked, 'timezone' => 'UTC', - 'register_date' => Temporal::convert(), + 'register_date' => Temporal::utcNow(), 'default-location' => '' ]); @@ -613,7 +613,7 @@ class User dba::insert('userd', ['username' => $user['nickname']]); // The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php) - dba::update('user', ['account_removed' => true, 'account_expires_on' => Temporal::convert()], ['uid' => $uid]); + dba::update('user', ['account_removed' => true, 'account_expires_on' => Temporal::utcNow()], ['uid' => $uid]); Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid); // Send an update to the directory diff --git a/src/Module/Login.php b/src/Module/Login.php index 790fc3de8e..e922094d61 100644 --- a/src/Module/Login.php +++ b/src/Module/Login.php @@ -121,7 +121,7 @@ class Login extends BaseModule // if we haven't failed up this point, log them in. $_SESSION['remember'] = $_POST['remember']; - $_SESSION['last_login_date'] = Temporal::convert(); + $_SESSION['last_login_date'] = Temporal::utcNow(); authenticate_success($record, true, true); if (x($_SESSION, 'return_url')) { @@ -220,10 +220,10 @@ class Login extends BaseModule // stays logged in for a long time, e.g. with "Remember Me" $login_refresh = false; if (!x($_SESSION['last_login_date'])) { - $_SESSION['last_login_date'] = Temporal::convert(); + $_SESSION['last_login_date'] = Temporal::utcNow(); } if (strcmp(Temporal::convert('now - 12 hours'), $_SESSION['last_login_date']) > 0) { - $_SESSION['last_login_date'] = Temporal::convert(); + $_SESSION['last_login_date'] = Temporal::utcNow(); $login_refresh = true; } authenticate_success($user, false, false, $login_refresh); diff --git a/src/Network/FKOAuth1.php b/src/Network/FKOAuth1.php index 7c8f56a64a..f7f8f16417 100644 --- a/src/Network/FKOAuth1.php +++ b/src/Network/FKOAuth1.php @@ -68,7 +68,7 @@ class FKOAuth1 extends OAuthServer $_SESSION['cid'] = $a->cid; } - dba::update('user', ['login_date' => Temporal::convert()], ['uid' => $_SESSION['uid']]); + dba::update('user', ['login_date' => Temporal::utcNow()], ['uid' => $_SESSION['uid']]); Addon::callHooks('logged_in', $a->user); } diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 3145e21f2b..998a6022f3 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -1406,8 +1406,8 @@ class DFRN VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", intval($contact["uid"]), intval($contact["id"]), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), dbesc(Temporal::convert($birthday)), dbesc(Temporal::convert($birthday . " + 1 day ")), dbesc($bdtext), @@ -1889,7 +1889,7 @@ class DFRN intval($suggest["cid"]), dbesc($suggest["body"]), dbesc($hash), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval(0) ); @@ -2086,7 +2086,7 @@ class DFRN } $fields = ['title' => $item["title"], 'body' => $item["body"], - 'tag' => $item["tag"], 'changed' => Temporal::convert(), + 'tag' => $item["tag"], 'changed' => Temporal::utcNow(), 'edited' => Temporal::convert($item["edited"])]; $condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]]; @@ -2836,7 +2836,7 @@ class DFRN `body` = '', `title` = '' WHERE `parent-uri` = '%s' AND `uid` IN (0, %d)", dbesc($when), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), dbesc($uri), intval($importer["uid"]) ); @@ -2849,7 +2849,7 @@ class DFRN `body` = '', `title` = '' WHERE `uri` = '%s' AND `uid` IN (0, %d)", dbesc($when), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), dbesc($uri), intval($importer["uid"]) ); diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index db18fbb478..afd7359650 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -77,7 +77,7 @@ class Diaspora $r = q( "INSERT INTO `contact` (`uid`, `created`, `name`, `nick`, `addr`, `url`, `nurl`, `batch`, `network`, `rel`, `blocked`, `pending`, `writable`, `name-date`, `uri-date`, `avatar-date`) VALUES (0, '%s', '%s', 'relay', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, '%s', '%s', '%s')", - Temporal::convert(), + Temporal::utcNow(), dbesc($addr), dbesc($addr), dbesc($server), @@ -85,9 +85,9 @@ class Diaspora dbesc($batch), dbesc(NETWORK_DIASPORA), intval(CONTACT_IS_FOLLOWER), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()) + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()) ); $relais = q("SELECT `batch`, `id`, `name`,`network` FROM `contact` WHERE `uid` = 0 AND `batch` = '%s' LIMIT 1", dbesc($batch)); @@ -871,7 +871,7 @@ class Diaspora dbesc($arr["confirm"]), dbesc($arr["alias"]), dbesc($arr["pubkey"]), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), dbesc($arr["url"]), dbesc($arr["network"]) ); @@ -894,7 +894,7 @@ class Diaspora dbesc($arr["network"]), dbesc($arr["alias"]), dbesc($arr["pubkey"]), - dbesc(Temporal::convert()) + dbesc(Temporal::utcNow()) ); } @@ -1656,7 +1656,7 @@ class Diaspora if (isset($data->created_at)) { $created_at = Temporal::convert(notags(unxmlify($data->created_at))); } else { - $created_at = Temporal::convert(); + $created_at = Temporal::utcNow(); } if (isset($data->thread_parent_guid)) { @@ -1831,7 +1831,7 @@ class Diaspora dba::unlock(); - dba::update('conv', ['updated' => Temporal::convert()], ['id' => $conversation["id"]]); + dba::update('conv', ['updated' => Temporal::utcNow()], ['id' => $conversation["id"]]); notification( [ @@ -1897,7 +1897,7 @@ class Diaspora dbesc($guid), dbesc($author), dbesc($created_at), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), dbesc($subject), dbesc($participants) ); @@ -2164,7 +2164,7 @@ class Diaspora dba::unlock(); - dba::update('conv', ['updated' => Temporal::convert()], ['id' => $conversation["id"]]); + dba::update('conv', ['updated' => Temporal::utcNow()], ['id' => $conversation["id"]]); return true; } @@ -2331,7 +2331,7 @@ class Diaspora dbesc($name), dbesc($nick), dbesc($author), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), dbesc($birthday), dbesc($location), dbesc($about), @@ -2537,7 +2537,7 @@ class Diaspora intval($importer["uid"]), dbesc($ret["network"]), dbesc($ret["addr"]), - Temporal::convert(), + Temporal::utcNow(), dbesc($ret["url"]), dbesc(normalise_link($ret["url"])), dbesc($batch), @@ -2580,7 +2580,7 @@ class Diaspora 0, dbesc(L10n::t("Sharing notification from Diaspora network")), dbesc($hash), - dbesc(Temporal::convert()) + dbesc(Temporal::utcNow()) ); } else { // automatic friend approval @@ -2611,8 +2611,8 @@ class Diaspora WHERE `id` = %d ", intval($new_relation), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), intval($contact_record["id"]) ); @@ -2852,8 +2852,8 @@ class Diaspora 'deleted' => true, 'title' => '', 'body' => '', - 'edited' => Temporal::convert(), - 'changed' => Temporal::convert()], + 'edited' => Temporal::utcNow(), + 'changed' => Temporal::utcNow()], ['id' => $item["id"]] ); diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index b3c85f377e..c98b8ddec0 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -199,7 +199,7 @@ class OStatus $contact["location"] = $value; } - $contact['name-date'] = Temporal::convert(); + $contact['name-date'] = Temporal::utcNow(); dba::update('contact', $contact, ['id' => $contact["id"]], $current); @@ -220,7 +220,7 @@ class OStatus 'nurl' => normalise_link($author["author-link"]), 'nick' => $contact["nick"], 'alias' => $contact["alias"], 'about' => $contact["about"], 'location' => $contact["location"], - 'success_update' => Temporal::convert(), 'last-update' => Temporal::convert()]; + 'success_update' => Temporal::utcNow(), 'last-update' => Temporal::utcNow()]; dba::update('contact', $fields, ['id' => $cid], $old_contact); @@ -558,7 +558,7 @@ class OStatus dba::update( 'item', ['deleted' => true, 'title' => '', 'body' => '', - 'edited' => Temporal::convert(), 'changed' => Temporal::convert()], + 'edited' => Temporal::utcNow(), 'changed' => Temporal::utcNow()], ['id' => $deleted["id"]] ); diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 04497f16ba..aea68eb998 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -315,7 +315,7 @@ class PortableContact $contact = ["url" => $profile]; if ($gcontacts[0]["created"] <= NULL_DATE) { - $contact['created'] = Temporal::convert(); + $contact['created'] = Temporal::utcNow(); } if ($force) { @@ -338,7 +338,7 @@ class PortableContact if ($server_url != "") { if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) { if ($force) { - $fields = ['last_failure' => Temporal::convert()]; + $fields = ['last_failure' => Temporal::utcNow()]; dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); } @@ -412,14 +412,14 @@ class PortableContact // Set the date of the last contact /// @todo By now the function "update_gcontact" doesn't work with this field - //$contact["last_contact"] = Temporal::convert(); + //$contact["last_contact"] = Temporal::utcNow(); $contact = array_merge($contact, $noscrape); GContact::update($contact); if (trim($noscrape["updated"]) != "") { - $fields = ['last_contact' => Temporal::convert()]; + $fields = ['last_contact' => Temporal::utcNow()]; dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG); @@ -468,7 +468,7 @@ class PortableContact } if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) { - $fields = ['last_failure' => Temporal::convert()]; + $fields = ['last_failure' => Temporal::utcNow()]; dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG); @@ -484,7 +484,7 @@ class PortableContact $feedret = Network::curl($data["poll"]); if (!$feedret["success"]) { - $fields = ['last_failure' => Temporal::convert()]; + $fields = ['last_failure' => Temporal::utcNow()]; dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG); @@ -533,7 +533,7 @@ class PortableContact public static function updateNeeded($created, $updated, $last_failure, $last_contact) { - $now = strtotime(Temporal::convert()); + $now = strtotime(Temporal::utcNow()); if ($updated > $last_contact) { $contact_time = strtotime($updated); @@ -922,7 +922,7 @@ class PortableContact $gserver = dba::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]); if (DBM::is_result($gserver)) { if ($gserver["created"] <= NULL_DATE) { - $fields = ['created' => Temporal::convert()]; + $fields = ['created' => Temporal::utcNow()]; $condition = ['nurl' => normalise_link($server_url)]; dba::update('gserver', $fields, $condition); } @@ -969,7 +969,7 @@ class PortableContact // Mastodon uses the "@" for user profiles. // But this can be misunderstood. if (parse_url($server_url, PHP_URL_USER) != '') { - dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]); + dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]); return false; } @@ -985,7 +985,7 @@ class PortableContact if (DBM::is_result($gserver) && ($orig_server_url == $server_url) && ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) { logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG); - dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]); + dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]); return false; } @@ -1000,7 +1000,7 @@ class PortableContact // Quit if there is a timeout if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) { logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG); - dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]); + dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]); return false; } @@ -1332,9 +1332,9 @@ class PortableContact if ($failure) { $last_contact = $orig_last_contact; - $last_failure = Temporal::convert(); + $last_failure = Temporal::utcNow(); } else { - $last_contact = Temporal::convert(); + $last_contact = Temporal::utcNow(); $last_failure = $orig_last_failure; } @@ -1362,7 +1362,7 @@ class PortableContact dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]); } elseif (!$failure) { $fields['nurl'] = normalise_link($server_url); - $fields['created'] = Temporal::convert(); + $fields['created'] = Temporal::utcNow(); dba::insert('gserver', $fields); } logger("End discovery for server " . $server_url, LOGGER_DEBUG); @@ -1526,7 +1526,7 @@ class PortableContact } } - $fields = ['last_poco_query' => Temporal::convert()]; + $fields = ['last_poco_query' => Temporal::utcNow()]; dba::update('gserver', $fields, ['nurl' => $server["nurl"]]); return true; @@ -1535,7 +1535,7 @@ class PortableContact self::checkServer($server["url"], $server["network"], true); // If we couldn't reach the server, we will try it some time later - $fields = ['last_poco_query' => Temporal::convert()]; + $fields = ['last_poco_query' => Temporal::utcNow()]; dba::update('gserver', $fields, ['nurl' => $server["nurl"]]); return false; @@ -1561,7 +1561,7 @@ class PortableContact foreach ($r as $server) { if (!self::checkServer($server["url"], $server["network"])) { // The server is not reachable? Okay, then we will try it later - $fields = ['last_poco_query' => Temporal::convert()]; + $fields = ['last_poco_query' => Temporal::utcNow()]; dba::update('gserver', $fields, ['nurl' => $server["nurl"]]); continue; } diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 23e24b1235..3074e74dd6 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -73,7 +73,7 @@ class ParseUrl [ 'url' => normalise_link($url), 'guessing' => !$no_guessing, 'oembed' => $do_oembed, 'content' => serialize($data), - 'created' => Temporal::convert() + 'created' => Temporal::utcNow() ], true ); diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index 176e616477..eb0bbeb8e0 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -123,6 +123,17 @@ class Temporal ]); } + /** + * convert() shorthand for UTC now. + * + * @param string $format DateTime format string or Temporal constant + * @return string + */ + public static function utcNow($format = self::MYSQL) + { + return self::convert('now', 'UTC', 'UTC', $format); + } + /** * @brief General purpose date parse/convert/format function. * diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php index 0b497f6f17..07ddf8bee4 100644 --- a/src/Worker/Cron.php +++ b/src/Worker/Cron.php @@ -71,7 +71,7 @@ Class Cron { // once daily run birthday_updates and then expire in background $d1 = Config::get('system', 'last_expire_day'); - $d2 = intval(Temporal::convert('now', 'UTC', 'UTC', 'd')); + $d2 = intval(Temporal::utcNow('d')); if ($d2 != intval($d1)) { @@ -142,7 +142,7 @@ Class Cron { Addon::reload(); - $d = Temporal::convert(); + $d = Temporal::utcNow(); // Only poll from those with suitable relationships, // and which have a polling address and ignore Diaspora since @@ -218,33 +218,33 @@ Class Cron { */ switch ($contact['priority']) { case 5: - if (Temporal::convert('now') > Temporal::convert($t . " + 1 month")) { + if (Temporal::utcNow() > Temporal::convert($t . " + 1 month")) { $update = true; } break; case 4: - if (Temporal::convert('now') > Temporal::convert($t . " + 1 week")) { + if (Temporal::utcNow() > Temporal::convert($t . " + 1 week")) { $update = true; } break; case 3: - if (Temporal::convert('now') > Temporal::convert($t . " + 1 day")) { + if (Temporal::utcNow() > Temporal::convert($t . " + 1 day")) { $update = true; } break; case 2: - if (Temporal::convert('now') > Temporal::convert($t . " + 12 hour")) { + if (Temporal::utcNow() > Temporal::convert($t . " + 12 hour")) { $update = true; } break; case 1: - if (Temporal::convert('now') > Temporal::convert($t . " + 1 hour")) { + if (Temporal::utcNow() > Temporal::convert($t . " + 1 hour")) { $update = true; } break; case 0: default: - if (Temporal::convert('now') > Temporal::convert($t . " + ".$min_poll_interval." minute")) { + if (Temporal::utcNow() > Temporal::convert($t . " + ".$min_poll_interval." minute")) { $update = true; } break; diff --git a/src/Worker/CronHooks.php b/src/Worker/CronHooks.php index 7aaf2567fc..d8b97384e6 100644 --- a/src/Worker/CronHooks.php +++ b/src/Worker/CronHooks.php @@ -45,7 +45,7 @@ Class CronHooks { logger('cronhooks: start'); - $d = Temporal::convert(); + $d = Temporal::utcNow(); if (is_array($a->hooks) && array_key_exists("cron", $a->hooks)) { foreach ($a->hooks["cron"] as $hook) { diff --git a/src/Worker/DiscoverPoCo.php b/src/Worker/DiscoverPoCo.php index 5bcff6d1a7..480578c8f9 100644 --- a/src/Worker/DiscoverPoCo.php +++ b/src/Worker/DiscoverPoCo.php @@ -198,7 +198,7 @@ class DiscoverPoCo { } } else { q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'", - dbesc(Temporal::convert()), dbesc(normalise_link($user["url"]))); + dbesc(Temporal::utcNow()), dbesc(normalise_link($user["url"]))); } // Quit the loop after 3 minutes diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index ff08ed0943..6e69bc3aa8 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -44,7 +44,7 @@ class OnePoll return; } - $d = Temporal::convert(); + $d = Temporal::utcNow(); $contact = dba::selectFirst('contact', [], ['id' => $contact_id]); if (!DBM::is_result($contact)) { @@ -70,7 +70,7 @@ class OnePoll // Diaspora users, archived users and followers are only checked if they still exist. if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) { $last_updated = PortableContact::lastUpdated($contact["url"], true); - $updated = Temporal::convert(); + $updated = Temporal::utcNow(); if ($last_updated) { logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG); @@ -99,7 +99,7 @@ class OnePoll $contact['priority'] = intval($poll_interval); $hub_update = false; - if (Temporal::convert('now') > Temporal::convert($t . " + 1 day")) { + if (Temporal::utcNow() > Temporal::convert($t . " + 1 day")) { $hub_update = true; } } else { @@ -117,7 +117,7 @@ class OnePoll logger("Skipping probably dead contact ".$contact['url']); // set the last-update so we don't keep polling - dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]); + dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); return; } @@ -126,7 +126,7 @@ class OnePoll logger('Contact is marked dead'); // set the last-update so we don't keep polling - dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]); + dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); return; } else { Contact::unmarkForArchival($contact); @@ -137,7 +137,7 @@ class OnePoll logger('Ignore public contacts'); // set the last-update so we don't keep polling - dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]); + dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); return; } @@ -149,7 +149,7 @@ class OnePoll logger('No self contact for user '.$importer_uid); // set the last-update so we don't keep polling - dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]); + dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); return; } @@ -185,7 +185,7 @@ class OnePoll if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { // set the last-update so we don't keep polling - dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]); + dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); Contact::markForArchival($contact); return; } @@ -207,7 +207,7 @@ class OnePoll Contact::markForArchival($contact); // set the last-update so we don't keep polling - $fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()]; + $fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()]; self::updateContact($contact, $fields); return; } @@ -217,7 +217,7 @@ class OnePoll Contact::markForArchival($contact); - $fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()]; + $fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()]; self::updateContact($contact, $fields); return; } @@ -230,7 +230,7 @@ class OnePoll // we may not be friends anymore. Will keep trying for one month. // set the last-update so we don't keep polling - $fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()]; + $fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()]; self::updateContact($contact, $fields); Contact::markForArchival($contact); @@ -241,7 +241,7 @@ class OnePoll if ((intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) { // set the last-update so we don't keep polling - dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]); + dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); return; } @@ -276,7 +276,7 @@ class OnePoll logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id); // set the last-update so we don't keep polling - dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]); + dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); Contact::markForArchival($contact); return; } @@ -311,7 +311,7 @@ class OnePoll if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly']) { // set the last-update so we don't keep polling - dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]); + dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); return; } @@ -321,7 +321,7 @@ class OnePoll if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { // set the last-update so we don't keep polling - dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]); + dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); Contact::markForArchival($contact); return; } @@ -335,7 +335,7 @@ class OnePoll $mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1); if ($mail_disabled) { // set the last-update so we don't keep polling - dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]); + dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); Contact::markForArchival($contact); return; } @@ -355,7 +355,7 @@ class OnePoll unset($password); logger("Mail: Connect to " . $mailconf['user']); if ($mbox) { - $fields = ['last_check' => Temporal::convert()]; + $fields = ['last_check' => Temporal::utcNow()]; dba::update('mailacct', $fields, ['id' => $mailconf['id']]); logger("Mail: Connected to " . $mailconf['user']); } else { @@ -395,7 +395,7 @@ class OnePoll // Only delete when mails aren't automatically moved or deleted if (($mailconf['action'] != 1) && ($mailconf['action'] != 3)) if ($meta->deleted && ! $item['deleted']) { - $fields = ['deleted' => true, 'changed' => Temporal::convert()]; + $fields = ['deleted' => true, 'changed' => Temporal::utcNow()]; dba::update('item', $fields, ['id' => $item['id']]); } @@ -572,7 +572,7 @@ class OnePoll if (!strstr($xml, '<')) { logger('post_handshake: response from ' . $url . ' did not contain XML.'); - $fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()]; + $fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()]; self::updateContact($contact, $fields); Contact::markForArchival($contact); return; @@ -616,19 +616,19 @@ class OnePoll } } - $updated = Temporal::convert(); + $updated = Temporal::utcNow(); self::updateContact($contact, ['last-update' => $updated, 'success_update' => $updated]); dba::update('gcontact', ['last_contact' => $updated], ['nurl' => $contact['nurl']]); Contact::unmarkForArchival($contact); } elseif (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED])) { - $updated = Temporal::convert(); + $updated = Temporal::utcNow(); self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]); dba::update('gcontact', ['last_failure' => $updated], ['nurl' => $contact['nurl']]); Contact::markForArchival($contact); } else { - $updated = Temporal::convert(); + $updated = Temporal::utcNow(); dba::update('contact', ['last-update' => $updated], ['id' => $contact['id']]); } diff --git a/src/Worker/UpdateGContact.php b/src/Worker/UpdateGContact.php index 520dfed3b3..da307b4faf 100644 --- a/src/Worker/UpdateGContact.php +++ b/src/Worker/UpdateGContact.php @@ -42,7 +42,7 @@ class UpdateGContact } q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d", - dbesc(Temporal::convert()), intval($contact_id)); + dbesc(Temporal::utcNow()), intval($contact_id)); return; }