Cleaner code to avoid a couple PHP notices from accessing uninitialized variables in ostatus profile discovery (these cases hit checking diaspora accounts)

This commit is contained in:
Brion Vibber 2010-12-15 12:14:25 -08:00
parent 6c67114198
commit 0330bad688

View File

@ -1552,8 +1552,11 @@ class Ostatus_profile extends Memcached_DataObject
}
// Try the profile url (like foo.example.com or example.com/user/foo)
$profileUrl = ($object->link) ? $object->link : $hints['profileurl'];
if (!empty($object->link)) {
$profileUrl = $object->link;
} else if (!empty($hints['profileurl'])) {
$profileUrl = $hints['profileurl'];
}
if (!empty($profileUrl)) {
$nickname = self::nicknameFromURI($profileUrl);
@ -1584,9 +1587,11 @@ class Ostatus_profile extends Memcached_DataObject
protected static function nicknameFromURI($uri)
{
preg_match('/(\w+):/', $uri, $matches);
if (preg_match('/(\w+):/', $uri, $matches)) {
$protocol = $matches[1];
} else {
return null;
}
switch ($protocol) {
case 'acct':