diff options
author | friendica <info@friendica.com> | 2013-01-28 20:51:37 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2013-01-28 20:51:37 -0800 |
commit | 3cf3f7437ea4c25c7a7fdcf04bfcf72be2d32698 (patch) | |
tree | 7e64a861053f1b73aefc3961541fe921f7f58e0b /include/items.php | |
parent | 95415bff69a6dba17d9aa3ff02707c94872e75e4 (diff) | |
download | volse-hubzilla-3cf3f7437ea4c25c7a7fdcf04bfcf72be2d32698.tar.gz volse-hubzilla-3cf3f7437ea4c25c7a7fdcf04bfcf72be2d32698.tar.bz2 volse-hubzilla-3cf3f7437ea4c25c7a7fdcf04bfcf72be2d32698.zip |
It's really not supposed to be quite this chatty on the network - ah that's why. Oops.
Diffstat (limited to 'include/items.php')
-rwxr-xr-x | include/items.php | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/include/items.php b/include/items.php index 3e296177a..92e256ea9 100755 --- a/include/items.php +++ b/include/items.php @@ -515,10 +515,15 @@ function get_item_elements($x) { else return array(); - if(import_author_xchan($x['owner'])) - $arr['owner_xchan'] = base64url_encode(hash('whirlpool',$x['owner']['guid'] . $x['owner']['guid_sig'], true)); - else - return array(); + // save a potentially expensive lookup if author == owner + if($arr['author_xchan'] === base64url_encode(hash('whirlpool',$x['owner']['guid'] . $x['owner']['guid_sig'], true))) + $arr['owner_xchan'] = $arr['author_xchan']; + else { + if(import_author_xchan($x['owner'])) + $arr['owner_xchan'] = base64url_encode(hash('whirlpool',$x['owner']['guid'] . $x['owner']['guid_sig'], true)); + else + return array(); + } return $arr; @@ -527,13 +532,20 @@ function get_item_elements($x) { function import_author_xchan($x) { + $r = q("select hubloc_url from hubloc where hubloc_guid = '%s' and hubloc_guid_sig = '%s' and (hubloc_flags & %d) limit 1", dbesc($x['guid']), dbesc($x['guid_sig']), - intval(HUBLOG_FLAGS_PRIMARY) + intval(HUBLOC_FLAGS_PRIMARY) ); - if($r) + + if($r) { + logger('import_author_xchan: in cache', LOGGER_DEBUG); return true; + } + + logger('import_author_xchan: entry not in cache - probing: ' . print_r($x,true), LOGGER_DEBUG); + $them = array('hubloc_url' => $x['url'],'xchan_guid' => $x['guid'], 'xchan_guid_sig' => $x['guid_sig']); return zot_refresh($them); } |