]> git.mxchange.org Git - friendica.git/commitdiff
Fix for incorrect datetime values
authorMichael <heluecht@pirati.ca>
Wed, 21 Mar 2018 05:20:55 +0000 (05:20 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 21 Mar 2018 05:20:55 +0000 (05:20 +0000)
include/event.php
src/Protocol/PortableContact.php

index 9172e3ecca229df592fc07cf252269b8479f2c27..0b6eb1020fccd452a28dbf6daac273c2e7827cc5 100644 (file)
@@ -241,8 +241,8 @@ function event_store($arr) {
 
        $a = get_app();
 
-       $arr['created'] = (($arr['created'])     ? $arr['created']         : DateTimeFormat::utcNow());
-       $arr['edited']  = (($arr['edited'])      ? $arr['edited']          : DateTimeFormat::utcNow());
+       $arr['created'] = (($arr['created'])     ? DateTimeFormat::utc($arr['created']) : DateTimeFormat::utcNow());
+       $arr['edited']  = (($arr['edited'])      ? DateTimeFormat::utc($arr['edited'])  : DateTimeFormat::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']));
index d10c4db3201d38683b0ddba8e89c9eeb4a8c857c..2cadf574f9e31e2df385f75ad27a4e0bb1bec789 100644 (file)
@@ -945,6 +945,15 @@ class PortableContact
                        $register_policy = $gserver["register_policy"];
                        $registered_users = $gserver["registered-users"];
 
+                       // See discussion under https://forum.friendi.ca/display/0b6b25a8135aabc37a5a0f5684081633
+                       // It can happen that a zero date is in the database, but storing it again is forbidden.
+                       if ($last_contact < NULL_DATE) {
+                               $last_contact = NULL_DATE;
+                       }
+                       if ($last_failure < NULL_DATE) {
+                               $last_failure = NULL_DATE;
+                       }
+
                        if (!$force && !self::updateNeeded($gserver["created"], "", $last_failure, $last_contact)) {
                                logger("Use cached data for server ".$server_url, LOGGER_DEBUG);
                                return ($last_contact >= $last_failure);