Merge pull request #3353 from annando/1704-empty-contacts

Handle the case when the given contact url or address is empty
This commit is contained in:
Hypolite Petovan 2017-04-18 16:20:33 -04:00 committed by GitHub
commit f1aed292db

View file

@ -212,6 +212,10 @@ function unmark_for_death($contact) {
function get_contact_details_by_url($url, $uid = -1, $default = array()) { function get_contact_details_by_url($url, $uid = -1, $default = array()) {
static $cache = array(); static $cache = array();
if ($url == '') {
return $default;
}
if ($uid == -1) { if ($uid == -1) {
$uid = local_user(); $uid = local_user();
} }
@ -328,6 +332,10 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
function get_contact_details_by_addr($addr, $uid = -1) { function get_contact_details_by_addr($addr, $uid = -1) {
static $cache = array(); static $cache = array();
if ($addr == '') {
return array();
}
if ($uid == -1) { if ($uid == -1) {
$uid = local_user(); $uid = local_user();
} }
@ -534,6 +542,10 @@ function get_contact($url, $uid = 0, $no_update = false) {
$data = array(); $data = array();
$contact_id = 0; $contact_id = 0;
if ($url == '') {
return 0;
}
// We first try the nurl (http://server.tld/nick), most common case // We first try the nurl (http://server.tld/nick), most common case
$contacts = q("SELECT `id`, `avatar-date` FROM `contact` $contacts = q("SELECT `id`, `avatar-date` FROM `contact`
WHERE `nurl` = '%s' WHERE `nurl` = '%s'