Only update if there is a change

This commit is contained in:
Michael 2017-08-30 19:33:16 +00:00
parent 0083c16e87
commit 1cc50a80f4
2 changed files with 24 additions and 4 deletions

View file

@ -2200,6 +2200,10 @@ function update_gcontact($contact) {
$contact["updated"] = dbm::date(); $contact["updated"] = dbm::date();
} }
if ($contact["network"] == NETWORK_TWITTER) {
$contact["server_url"] = 'http://twitter.com';
}
if ($contact["server_url"] == "") { if ($contact["server_url"] == "") {
$data = Probe::uri($contact["url"]); $data = Probe::uri($contact["url"]);
if ($data["network"] != NETWORK_PHANTOM) { if ($data["network"] != NETWORK_PHANTOM) {

View file

@ -392,16 +392,25 @@ class Probe {
'about' => $data['about'], 'about' => $data['about'],
'notify' => $data['notify'], 'notify' => $data['notify'],
'network' => $data['network'], 'network' => $data['network'],
'server_url' => $data['baseurl'], 'server_url' => $data['baseurl']);
'updated' => dbm::date());
$fieldnames = array();
foreach ($fields AS $key => $val) { foreach ($fields AS $key => $val) {
if (empty($val)) { if (empty($val)) {
unset($fields[$key]); 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'], $fields = array('name' => $data['name'],
'nick' => $data['nick'], 'nick' => $data['nick'],
@ -420,14 +429,21 @@ class Probe {
'network' => $data['network'], 'network' => $data['network'],
'success_update' => dbm::date()); 'success_update' => dbm::date());
$fieldnames = array();
foreach ($fields AS $key => $val) { foreach ($fields AS $key => $val) {
if (empty($val)) { if (empty($val)) {
unset($fields[$key]); unset($fields[$key]);
} else {
$fieldnames[] = $key;
} }
} }
$condition = array('nurl' => normalise_link($data["url"]), 'self' => false, 'uid' => 0); $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);
} }
} }