1
0
Fork 0

Some precaution to avoid overwriting of existing data with blanks

This commit is contained in:
Michael Vogel 2015-07-12 11:19:40 +02:00
parent fe137a92ef
commit 0ac75deee1
3 changed files with 15 additions and 2 deletions

View file

@ -1,7 +1,12 @@
<?php <?php
function update_contact($id) { function update_contact($id) {
$r = q("SELECT `url`, `network` FROM `contact` WHERE `id` = %d", intval($id)); /*
Warning: Never ever fetch the public key via probe_url and write it into the contacts.
This will reliably kill your communication with Friendica contacts.
*/
$r = q("SELECT `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `network` FROM `contact` WHERE `id` = %d", intval($id));
if (!$r) if (!$r)
return; return;
@ -11,6 +16,11 @@ function update_contact($id) {
if ($ret["network"] != $r[0]["network"]) if ($ret["network"] != $r[0]["network"])
return; return;
// make sure to not overwrite existing values with blank entries
foreach ($ret AS $key => $val)
if (isset($r[0][$key]) AND ($r[0][$key] != "") AND ($val == ""))
$ret[$key] = $r[0][$key];
q("UPDATE `contact` SET `url` = '%s', `nurl` = '%s', `addr` = '%s', `alias` = '%s', `batch` = '%s', `notify` = '%s', `poll` = '%s', `poco` = '%s', `name` = '%s', `nick` = '%s' WHERE `id` = %d", q("UPDATE `contact` SET `url` = '%s', `nurl` = '%s', `addr` = '%s', `alias` = '%s', `batch` = '%s', `notify` = '%s', `poll` = '%s', `poco` = '%s', `name` = '%s', `nick` = '%s' WHERE `id` = %d",
dbesc($ret['url']), dbesc($ret['url']),
dbesc(normalise_link($ret['url'])), dbesc(normalise_link($ret['url'])),

View file

@ -2076,7 +2076,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
$final_dfrn_id = substr($final_dfrn_id,2); $final_dfrn_id = substr($final_dfrn_id,2);
if($final_dfrn_id != $orig_id) { if($final_dfrn_id != $orig_id) {
logger('dfrn_deliver: wrong dfrn_id. Original: '.$orig_id.' Target: '.$final_dfrn_id.' Test: '.$test); logger('dfrn_deliver: wrong dfrn_id.');
// did not decode properly - cannot trust this site // did not decode properly - cannot trust this site
return 3; return 3;
} }

View file

@ -308,6 +308,9 @@ class Item extends BaseObject {
if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"])) if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"]))
unset($buttons["like"]); unset($buttons["like"]);
// Likes don't federate at OStatus
if (($item["item_network"] == NETWORK_OSTATUS) AND isset($buttons["like"]))
unset($buttons["like"]);
$tmp_item = array( $tmp_item = array(
'template' => $this->get_template(), 'template' => $this->get_template(),