Merge pull request #3632 from annando/bugfix-3630

Bugfix for PR 3630
This commit is contained in:
Tobias Diekershoff 2017-08-15 07:41:30 +02:00 committed by GitHub
commit dd08e22bea
4 changed files with 14 additions and 7 deletions

View file

@ -210,23 +210,27 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
FROM `contact` WHERE `nurl` = ? AND `uid` = ?",
normalise_link($url), $uid);
$r = dba::inArray($s);
// Fetch the data from the contact table with "uid=0" (which is filled automatically)
if (!dbm::is_result($s))
if (!dbm::is_result($r)) {
$s = dba::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
FROM `contact` WHERE `nurl` = ? AND `uid` = 0",
normalise_link($url));
$r = dba::inArray($s);
}
// Fetch the data from the gcontact table
if (!dbm::is_result($s))
if (!dbm::is_result($r)) {
$s = dba::p("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`,
`keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, `community` AS `forum`, 0 AS `prv`, `community`, `contact-type`, `birthday`, 0 AS `self`
FROM `gcontact` WHERE `nurl` = ?",
normalise_link($url));
if (dbm::is_result($s)) {
$r = dba::inArray($s);
}
if (dbm::is_result($r)) {
// If there is more than one entry we filter out the connector networks
if (count($r) > 1) {
foreach ($r AS $id => $result) {

View file

@ -1338,6 +1338,10 @@ class dba {
* @return array Data array
*/
static public function inArray($stmt, $do_close = true) {
if (is_bool($stmt)) {
return $stmt;
}
$data = array();
while ($row = self::fetch($stmt)) {
$data[] = $row;

View file

@ -49,7 +49,7 @@ function profile_load(App $a, $nickname, $profile = 0, $profiledata = array()) {
$pdata = get_profiledata_by_nick($nickname, $user[0]['uid'], $profile);
if (($pdata === false) || (!count($pdata)) && !count($profiledata)) {
if (empty($pdata) && empty($profiledata)) {
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
notice( t('Requested profile is not available.') . EOL );
$a->error = 404;

View file

@ -39,7 +39,7 @@ function hovercard_content() {
// If a contact is connected the url is internally changed to "redir/CID". We need the pure url to search for
// the contact. So we strip out the contact id from the internal url and look in the contact table for
// the real url (nurl)
if(local_user() && strpos($profileurl, "redir/") === 0) {
if (local_user() && strpos($profileurl, "redir/") === 0) {
$cid = intval(substr($profileurl, 6));
$r = dba::select('contact', array('nurl', 'self'), array('id' => $cid), array('limit' => 1));
$profileurl = ($r["nurl"] ? $r["nurl"] : "");
@ -52,7 +52,6 @@ function hovercard_content() {
// Search for contact data
$contact = get_contact_details_by_url($nurl);
}
if(!is_array($contact))
return;