Browse Source

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

pull/5438/head
Hypolite Petovan 3 years ago
committed by Hypolite Petovan
parent
commit
8ddb94ef06
  1. 6
      mod/network.php
  2. 5
      src/Database/DBStructure.php
  3. 3
      src/Model/Conversation.php
  4. 4
      src/Model/GContact.php
  5. 2
      src/Network/Probe.php
  6. 2
      src/Protocol/DFRN.php
  7. 5
      update.php

6
mod/network.php

@ -480,9 +480,9 @@ function networkThreadedView(App $a, $update, $parent)
$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'])) {
$last_received = DBM::date($_GET['last_received']);
$last_commented = DBM::date($_GET['last_commented']);
$last_created = DBM::date($_GET['last_created']);
$last_received = DateTimeFormat::utc($_GET['last_received']);
$last_commented = DateTimeFormat::utc($_GET['last_commented']);
$last_created = DateTimeFormat::utc($_GET['last_created']);
$last_id = intval($_GET['last_id']);
} else {
$last_received = '';

5
src/Database/DBStructure.php

@ -8,6 +8,7 @@ use Exception;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Util\DateTimeFormat;
require_once 'boot.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) {
if ($action && !$install) {
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 = '';
@ -469,7 +470,7 @@ class DBStructure
if ($action) {
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

3
src/Model/Conversation.php

@ -6,6 +6,7 @@ namespace Friendica\Model;
use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
require_once "include/dba.php";
@ -27,7 +28,7 @@ class Conversation
*/
public static function insert($arr) {
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'])) {
$conversation['reply-to-uri'] = $arr['parent-uri'];

4
src/Model/GContact.php

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

2
src/Network/Probe.php

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

2
src/Protocol/DFRN.php

@ -1748,7 +1748,7 @@ class DFRN
dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["about"]), dbesc($contact["location"]),
dbesc($contact["addr"]), dbesc($contact["keywords"]), dbesc($contact["bdyear"]),
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"])
);
}

5
update.php

@ -10,6 +10,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
require_once 'include/dba.php';
@ -191,7 +192,7 @@ WHERE `hook` LIKE 'plugin_%'");
function update_1260() {
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`
WHERE `owner-id` = 0 AND `owner-link` != ''");
@ -237,7 +238,7 @@ function update_1261() {
function update_1278() {
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_PERSONAL_NOTE], ['type' => 'note']);

Loading…
Cancel
Save