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:
parent
6c67114198
commit
0330bad688
@ -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);
|
||||
|
||||
$protocol = $matches[1];
|
||||
if (preg_match('/(\w+):/', $uri, $matches)) {
|
||||
$protocol = $matches[1];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch ($protocol) {
|
||||
case 'acct':
|
||||
|
Loading…
Reference in New Issue
Block a user