1
0
Fork 0

Use DateTimeFormat::utc() instead of DBM::date()

This commit is contained in:
Hypolite Petovan 2018-07-21 08:25:11 -04:00 committed by Hypolite Petovan
parent c55e389bbc
commit 8ddb94ef06
7 changed files with 15 additions and 12 deletions

View file

@ -480,9 +480,9 @@ function networkThreadedView(App $a, $update, $parent)
$rawmode = (isset($_GET['mode']) AND ( $_GET['mode'] == 'raw')); $rawmode = (isset($_GET['mode']) AND ( $_GET['mode'] == 'raw'));
if (isset($_GET['last_received']) && isset($_GET['last_commented']) && isset($_GET['last_created']) && isset($_GET['last_id'])) { if (isset($_GET['last_received']) && isset($_GET['last_commented']) && isset($_GET['last_created']) && isset($_GET['last_id'])) {
$last_received = DBM::date($_GET['last_received']); $last_received = DateTimeFormat::utc($_GET['last_received']);
$last_commented = DBM::date($_GET['last_commented']); $last_commented = DateTimeFormat::utc($_GET['last_commented']);
$last_created = DBM::date($_GET['last_created']); $last_created = DateTimeFormat::utc($_GET['last_created']);
$last_id = intval($_GET['last_id']); $last_id = intval($_GET['last_id']);
} else { } else {
$last_received = ''; $last_received = '';

View file

@ -8,6 +8,7 @@ use Exception;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Util\DateTimeFormat;
require_once 'boot.php'; require_once 'boot.php';
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -207,7 +208,7 @@ class DBStructure
public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) { public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) {
if ($action && !$install) { if ($action && !$install) {
Config::set('system', 'maintenance', 1); Config::set('system', 'maintenance', 1);
Config::set('system', 'maintenance_reason', L10n::t('%s: Database update', DBM::date().' '.date('e'))); Config::set('system', 'maintenance_reason', L10n::t('%s: Database update', DateTimeFormat::utcNow().' '.date('e')));
} }
$errors = ''; $errors = '';
@ -469,7 +470,7 @@ class DBStructure
if ($action) { if ($action) {
if (!$install) { if (!$install) {
Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name)); Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DateTimeFormat::utcNow().' '.date('e'), $name));
} }
// Ensure index conversion to unique removes duplicates // Ensure index conversion to unique removes duplicates

View file

@ -6,6 +6,7 @@ namespace Friendica\Model;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
require_once "include/dba.php"; require_once "include/dba.php";
@ -27,7 +28,7 @@ class Conversation
*/ */
public static function insert($arr) { public static function insert($arr) {
if (in_array(defaults($arr, 'network', NETWORK_PHANTOM), [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]) && !empty($arr['uri'])) { if (in_array(defaults($arr, 'network', NETWORK_PHANTOM), [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]) && !empty($arr['uri'])) {
$conversation = ['item-uri' => $arr['uri'], 'received' => DBM::date()]; $conversation = ['item-uri' => $arr['uri'], 'received' => DateTimeFormat::utcNow()];
if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) { if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) {
$conversation['reply-to-uri'] = $arr['parent-uri']; $conversation['reply-to-uri'] = $arr['parent-uri'];

View file

@ -815,7 +815,7 @@ class GContact
self::fixAlternateContactAddress($contact); self::fixAlternateContactAddress($contact);
if (!isset($contact["updated"])) { if (!isset($contact["updated"])) {
$contact["updated"] = DBM::date(); $contact["updated"] = DateTimeFormat::utcNow();
} }
if ($contact["network"] == NETWORK_TWITTER) { if ($contact["network"] == NETWORK_TWITTER) {
@ -858,7 +858,7 @@ class GContact
logger("Update gcontact for ".$contact["url"], LOGGER_DEBUG); logger("Update gcontact for ".$contact["url"], LOGGER_DEBUG);
$condition = ['`nurl` = ? AND (`generation` = 0 OR `generation` >= ?)', $condition = ['`nurl` = ? AND (`generation` = 0 OR `generation` >= ?)',
normalise_link($contact["url"]), $contact["generation"]]; normalise_link($contact["url"]), $contact["generation"]];
$contact["updated"] = DBM::date($contact["updated"]); $contact["updated"] = DateTimeFormat::utc($contact["updated"]);
$updated = ['photo' => $contact['photo'], 'name' => $contact['name'], $updated = ['photo' => $contact['photo'], 'name' => $contact['name'],
'nick' => $contact['nick'], 'addr' => $contact['addr'], 'nick' => $contact['nick'], 'addr' => $contact['addr'],

View file

@ -411,7 +411,7 @@ class Probe
} }
} }
$fields['updated'] = DBM::date(); $fields['updated'] = DateTimeFormat::utcNow();
$condition = ['nurl' => normalise_link($data["url"])]; $condition = ['nurl' => normalise_link($data["url"])];

View file

@ -1748,7 +1748,7 @@ class DFRN
dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["about"]), dbesc($contact["location"]), dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["about"]), dbesc($contact["location"]),
dbesc($contact["addr"]), dbesc($contact["keywords"]), dbesc($contact["bdyear"]), dbesc($contact["addr"]), dbesc($contact["keywords"]), dbesc($contact["bdyear"]),
dbesc($contact["bd"]), intval($contact["hidden"]), dbesc($contact["xmpp"]), dbesc($contact["bd"]), intval($contact["hidden"]), dbesc($contact["xmpp"]),
dbesc(DBM::date($contact["name-date"])), dbesc(DBM::date($contact["uri-date"])), dbesc(DateTimeFormat::utc($contact["name-date"])), dbesc(DateTimeFormat::utc($contact["uri-date"])),
intval($contact["id"]), dbesc($contact["network"]) intval($contact["id"]), dbesc($contact["network"])
); );
} }

View file

@ -10,6 +10,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -191,7 +192,7 @@ WHERE `hook` LIKE 'plugin_%'");
function update_1260() { function update_1260() {
Config::set('system', 'maintenance', 1); Config::set('system', 'maintenance', 1);
Config::set('system', 'maintenance_reason', L10n::t('%s: Updating author-id and owner-id in item and thread table. ', DBM::date().' '.date('e'))); Config::set('system', 'maintenance_reason', L10n::t('%s: Updating author-id and owner-id in item and thread table. ', DateTimeFormat::utcNow().' '.date('e')));
$items = DBA::p("SELECT `id`, `owner-link`, `owner-name`, `owner-avatar`, `network` FROM `item` $items = DBA::p("SELECT `id`, `owner-link`, `owner-name`, `owner-avatar`, `network` FROM `item`
WHERE `owner-id` = 0 AND `owner-link` != ''"); WHERE `owner-id` = 0 AND `owner-link` != ''");
@ -237,7 +238,7 @@ function update_1261() {
function update_1278() { function update_1278() {
Config::set('system', 'maintenance', 1); Config::set('system', 'maintenance', 1);
Config::set('system', 'maintenance_reason', L10n::t('%s: Updating post-type.', DBM::date().' '.date('e'))); Config::set('system', 'maintenance_reason', L10n::t('%s: Updating post-type.', DateTimeFormat::utcNow().' '.date('e')));
Item::update(['post-type' => Item::PT_PAGE], ['bookmark' => true]); Item::update(['post-type' => Item::PT_PAGE], ['bookmark' => true]);
Item::update(['post-type' => Item::PT_PERSONAL_NOTE], ['type' => 'note']); Item::update(['post-type' => Item::PT_PERSONAL_NOTE], ['type' => 'note']);