]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Cleaner code to avoid a couple PHP notices from accessing uninitialized variables...
authorBrion Vibber <brion@pobox.com>
Wed, 15 Dec 2010 20:14:25 +0000 (12:14 -0800)
committerBrion Vibber <brion@pobox.com>
Wed, 15 Dec 2010 20:14:25 +0000 (12:14 -0800)
plugins/OStatus/classes/Ostatus_profile.php

index b43a2b5f11fde33c05d8524808dd0e4def553117..e5b8939a9d3a78b0d387ff9dadb8ef5e39dc2142 100644 (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);
-
-        $protocol = $matches[1];
+        if (preg_match('/(\w+):/', $uri, $matches)) {
+            $protocol = $matches[1];
+        } else {
+            return null;
+        }
 
         switch ($protocol) {
         case 'acct':