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
1 changed files with 10 additions and 5 deletions

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