]> git.mxchange.org Git - friendica.git/commitdiff
Only update if there is a change
authorMichael <heluecht@pirati.ca>
Wed, 30 Aug 2017 19:33:16 +0000 (19:33 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 30 Aug 2017 19:33:16 +0000 (19:33 +0000)
include/socgraph.php
src/Network/Probe.php

index ac7f01bc34af1ec5809ed0022873e501dbf86290..621085b0eee30db9637aef2c9c6db57231d786e0 100644 (file)
@@ -2200,6 +2200,10 @@ function update_gcontact($contact) {
                $contact["updated"] = dbm::date();
        }
 
+       if ($contact["network"] == NETWORK_TWITTER) {
+               $contact["server_url"] = 'http://twitter.com';
+       }
+
        if ($contact["server_url"] == "") {
                $data = Probe::uri($contact["url"]);
                if ($data["network"] != NETWORK_PHANTOM) {
index af0895a8f4ff0287b4dbfe500d47aebe3f3d929a..f36cdf08edcc872b4fe7730f6fe3bbab5c160aeb 100644 (file)
@@ -392,16 +392,25 @@ class Probe {
                                                'about' => $data['about'],
                                                'notify' => $data['notify'],
                                                'network' => $data['network'],
-                                               'server_url' => $data['baseurl'],
-                                               'updated' => dbm::date());
+                                               'server_url' => $data['baseurl']);
+
+                               $fieldnames = array();
 
                                foreach ($fields AS $key => $val) {
                                        if (empty($val)) {
                                                unset($fields[$key]);
+                                       } else {
+                                               $fieldnames[] = $key;
                                        }
                                }
 
-                               dba::update('gcontact', $fields, array('nurl' => normalise_link($data["url"])));
+                               $fields['updated'] = dbm::date();
+
+                               $condition = array('nurl' => normalise_link($data["url"]));
+
+                               $old_fields = dba::select('gcontact', $fieldnames, $condition, array('limit' => 1));
+
+                               dba::update('gcontact', $fields, $condition, $old_fields);
 
                                $fields = array('name' => $data['name'],
                                                'nick' => $data['nick'],
@@ -420,14 +429,21 @@ class Probe {
                                                'network' => $data['network'],
                                                'success_update' => dbm::date());
 
+                               $fieldnames = array();
+
                                foreach ($fields AS $key => $val) {
                                        if (empty($val)) {
                                                unset($fields[$key]);
+                                       } else {
+                                               $fieldnames[] = $key;
                                        }
                                }
 
                                $condition = array('nurl' => normalise_link($data["url"]), 'self' => false, 'uid' => 0);
-                               dba::update('contact', $fields, $condition);
+
+                               $old_fields = dba::select('contact', $fieldnames, $condition, array('limit' => 1));
+
+                               dba::update('contact', $fields, $condition, $old_fields);
                        }
                }