]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Code cleanup and enabling User object's etc. getUri()
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 28 Apr 2014 12:08:42 +0000 (14:08 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 28 Apr 2014 12:08:42 +0000 (14:08 +0200)
14 files changed:
actions/foaf.php
classes/Profile.php
classes/User.php
lib/accountmover.php
lib/activityimporter.php
lib/activitymover.php
lib/useractivitystream.php
lib/util.php
plugins/AutoSandbox/AutoSandboxPlugin.php
plugins/OStatus/actions/usersalmon.php
plugins/OStatus/classes/FeedSub.php
plugins/OStatus/classes/Ostatus_profile.php
plugins/OStatus/scripts/fixup-shadow.php
tests/ActivityGenerationTests.php

index 83f7d97d5883cabad98d736fe753db24a94e9b6d..bcdc86d886c97348ce42d74c5280552a389654a9 100644 (file)
@@ -90,11 +90,10 @@ class FoafAction extends Action
 
         // This is the document about the user
 
-        $this->showPpd('', $this->user->uri);
+        $this->showPpd('', $this->user->getUri());
 
         // Would be nice to tell if they were a Person or not (e.g. a #person usertag?)
-        $this->elementStart('Agent', array('rdf:about' =>
-                                             $this->user->uri));
+        $this->elementStart('Agent', array('rdf:about' => $this->user->getUri()));
         if ($this->user->email) {
             $this->element('mbox_sha1sum', null, sha1('mailto:' . $this->user->email));
         }
@@ -158,7 +157,7 @@ class FoafAction extends Action
         }
 
         $person = $this->showMicrobloggingAccount($this->profile,
-                                     common_root_url(), $this->user->uri,
+                                     common_root_url(), $this->user->getUri(),
                                      /*$fetchSubscriptions*/true,
                                      /*$isSubscriber*/false);
 
@@ -171,7 +170,7 @@ class FoafAction extends Action
         if ($sub->find()) {
             while ($sub->fetch()) {
                 $profile = Profile::getKV('id', $sub->subscriber);
-                if (empty($profile)) {
+                if (!$profile instanceof Profile) {
                     common_debug('Got a bad subscription: '.print_r($sub,true));
                     continue;
                 }
@@ -209,7 +208,7 @@ class FoafAction extends Action
             $profile = Profile::getKV($id);
             $this->elementStart('Agent', array('rdf:about' => $uri));
             if ($type == BOTH) {
-                $this->element('knows', array('rdf:resource' => $this->user->uri));
+                $this->element('knows', array('rdf:resource' => $this->user->getUri()));
             }
             $this->showMicrobloggingAccount($profile,
                                    ($local == 'local') ? common_root_url() : null,
@@ -301,7 +300,7 @@ class FoafAction extends Action
             unset($sub);
         } else if ($isSubscriber) {
             // Just declare that they follow the user whose FOAF we're showing.
-            $this->element('sioc:follows', array('rdf:resource' => $this->user->uri . '#acct'));
+            $this->element('sioc:follows', array('rdf:resource' => $this->user->getUri() . '#acct'));
         }
 
         $this->elementEnd('OnlineAccount');
index 6adf059781ac3c933c263a8f9984da943dcbb47f..c40e0e0b17ccdada4a7e230b8210482cddc69072 100644 (file)
@@ -1389,6 +1389,11 @@ class Profile extends Managed_DataObject
         return $this->profileurl;
     }
 
+    public function getNickname()
+    {
+        return $this->nickname;
+    }
+
     /**
      * Returns the best URI for a profile. Plugins may override.
      *
@@ -1403,9 +1408,8 @@ class Profile extends Managed_DataObject
 
             // check for a local user first
             $user = User::getKV('id', $this->id);
-
-            if (!empty($user)) {
-                $uri = $user->uri;
+            if ($user instanceof User) {
+                $uri = $user->getUri();
             }
 
             Event::handle('EndGetProfileUri', array($this, &$uri));
index d0eba7f75b4d8c21b816d8452f1b1a3a6ecd1726..55e52772453f498e80ddfd19c24c9fd0f4400853 100644 (file)
@@ -132,6 +132,11 @@ class User extends Managed_DataObject
         return $this->_profile;
     }
 
+    public function getUri()
+    {
+        return $this->uri;
+    }
+
     function isSubscribed(Profile $other)
     {
         return $this->getProfile()->isSubscribed($other);
index 429b6c04656f1b00845613148146bc1f89bf792b..83314b49978d53ace8a732179db05a33b5f4242f 100644 (file)
@@ -86,7 +86,7 @@ class AccountMover extends QueueHandler
         $qm = QueueManager::get();
 
         foreach ($acts as $act) {
-            $qm->enqueue(array($act, $sink, $user->uri, $remote), 'actmove');
+            $qm->enqueue(array($act, $sink, $user->getUri(), $remote), 'actmove');
         }
 
         $this->log(LOG_INFO,
index 1c34b64d35db8b84826b8bcaf1734fae32e7eeb2..27f89225c2ba93ac49d30f1bace8d6ad61572a5c 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
-    // This check helps protect against security problems;
-    // your code file can't be executed directly from the web.
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Class comment
@@ -104,13 +100,13 @@ class ActivityImporter extends QueueHandler
             $other = $activity->actor;
             $otherUser = User::getKV('uri', $other->id);
 
-            if (!empty($otherUser)) {
-                $otherProfile = $otherUser->getProfile();
-            } else {
+            if (!$otherUser instanceof User) {
                 // TRANS: Client exception thrown when trying to force a remote user to subscribe.
                 throw new Exception(_('Cannot force remote user to subscribe.'));
             }
 
+            $otherProfile = $otherUser->getProfile();
+
             // XXX: don't do this for untrusted input!
 
             Subscription::start($otherProfile, $profile);
@@ -141,7 +137,7 @@ class ActivityImporter extends QueueHandler
 
         $group = User_group::getKV('uri', $uri);
 
-        if (empty($group)) {
+        if (!$group instanceof User_group) {
             $oprofile = Ostatus_profile::ensureActivityObjectProfile($activity->objects[0]);
             if (!$oprofile->isGroup()) {
                 // TRANS: Client exception thrown when trying to join a remote group that is not a group.
@@ -170,7 +166,7 @@ class ActivityImporter extends QueueHandler
 
         $notice = Notice::getKV('uri', $sourceUri);
 
-        if (!empty($notice)) {
+        if ($notice instanceof Notice) {
 
             common_log(LOG_INFO, "Notice {$sourceUri} already exists.");
 
@@ -180,8 +176,8 @@ class ActivityImporter extends QueueHandler
 
                 $uri = $profile->getUri();
 
-                if ($uri == $author->id) {
-                    common_log(LOG_INFO, "Updating notice author from $author->id to $user->uri");
+                if ($uri === $author->id) {
+                    common_log(LOG_INFO, sprintf('Updating notice author from %s to %s', $author->id, $user->getUri()));
                     $orig = clone($notice);
                     $notice->profile_id = $user->id;
                     $notice->update($orig);
@@ -244,9 +240,8 @@ class ActivityImporter extends QueueHandler
             // Maintain direct reply associations
             // @fixme what about conversation ID?
             if (!empty($activity->context->replyToID)) {
-                $orig = Notice::getKV('uri',
-                                          $activity->context->replyToID);
-                if (!empty($orig)) {
+                $orig = Notice::getKV('uri', $activity->context->replyToID);
+                if ($orig instanceof Notice) {
                     $options['reply_to'] = $orig->id;
                 }
             }
index d5edab5caacb007b73c9fb9745a82a5c3aace820..0493750d0877e5b8f8108011027e13b16eda9dc9 100644 (file)
@@ -121,7 +121,7 @@ class ActivityMover extends QueueHandler
             }
             break;
         case ActivityVerb::FOLLOW:
-            if ($act->actor->id == $user->uri) {
+            if ($act->actor->id === $user->getUri()) {
                 $this->log(LOG_INFO,
                            "Moving subscription to {$act->objects[0]->id} by ".
                            "{$act->actor->id} to {$remote->nickname}.");
index 246bdb5d90e97341be23607f79e27cb98d07144d..ce3e373724e96451743682377a08f713854f73b3 100644 (file)
@@ -154,7 +154,7 @@ class UserActivityStream extends AtomUserNoticeFeed
             try {
                 if ($format == Feed::ATOM) {
                     // Only show the author sub-element if it's different from default user
-                    $act->outputTo($this, false, ($act->actor->id != $this->user->uri));
+                    $act->outputTo($this, false, ($act->actor->id != $this->user->getUri()));
                 } else {
                     if ($haveOne) {
                         fwrite($handle, ",");
index ac1938e84413873ad2f3abd9ef19957b1ef30468..aa6a59c9aac3b8871abee5cd90d2a39c37555e92 100644 (file)
@@ -2048,7 +2048,7 @@ function common_profile_uri($profile)
         if (Event::handle('StartCommonProfileURI', array($profile, &$uri))) {
             $user = User::getKV('id', $profile->id);
             if ($user instanceof User) {
-                $uri = $user->uri;
+                $uri = $user->getUri();
             }
             Event::handle('EndCommonProfileURI', array($profile, &$uri));
         }
index 9e930c0cc4610d947ea15cbef1da9ce4df4a82bf..bffb84057297c3102c8aa1e3ae748b6c759650b1 100644 (file)
@@ -75,10 +75,12 @@ class AutoSandboxPlugin extends Plugin
 
          if (isset($this->contact)) {
              $contactuser = User::getKV('nickname', $this->contact);
-             if (!empty($contactuser)) {
-                 $contactlink = "@<a href=\"$contactuser->uri\">$contactuser->nickname</a>";
+             if ($contactuser instanceof User) {
+                 $contactlink = sprintf('@<a href="%s">%s</a>',
+                                        htmlspecialchars($contactuser->getProfile()->getUrl()),
+                                        htmlspecialchars($contactuser->getProfile()->getNickname()));
                  // TRANS: User instructions after registration.
-                 // TRANS: %s is a clickable e-mailaddress.
+                 // TRANS: %s is a clickable OStatus profile URL.
                  $instr = sprintf(_m('Note you will initially be "sandboxed" so your posts will not appear in the public timeline. '.
                    'Send a message to %s to speed up the unsandboxing process.'),$contactlink);
              }
index 296fd6c6c728b7fce36971129eebb541787c4f21..383b42b147d03423f2f826c51c6c4a895916640a 100644 (file)
@@ -91,9 +91,9 @@ class UsersalmonAction extends SalmonAction
                 throw new ClientException(_m('In reply to a notice not by this user and not mentioning this user.'));
             }
         } else if (!empty($context->attention)) {
-            if (!array_key_exists($this->user->uri, $context->attention) &&
+            if (!array_key_exists($this->user->getUri(), $context->attention) &&
                 !array_key_exists(common_profile_url($this->user->nickname), $context->attention)) {
-                common_log(LOG_ERR, "{$this->user->uri} not in attention list (".implode(',', array_keys($context->attention)).')');
+                common_log(LOG_ERR, $this->user->getUri() . "not in attention list (".implode(',', array_keys($context->attention)).')');
                 // TRANS: Client exception.
                 throw new ClientException(_m('To the attention of user(s), not including this one.'));
             }
@@ -103,9 +103,8 @@ class UsersalmonAction extends SalmonAction
         }
 
         $existing = Notice::getKV('uri', $this->activity->objects[0]->id);
-
-        if (!empty($existing)) {
-            common_log(LOG_ERR, "Not saving notice '{$existing->uri}'; already exists.");
+        if ($existing instanceof Notice) {
+            common_log(LOG_ERR, "Not saving notice '".$existing->getUri()."'; already exists.");
             return;
         }
 
@@ -120,7 +119,7 @@ class UsersalmonAction extends SalmonAction
     {
         $oprofile = $this->ensureProfile();
         if ($oprofile) {
-            common_log(LOG_INFO, "Setting up subscription from remote {$oprofile->uri} to local {$this->user->nickname}");
+            common_log(LOG_INFO, sprintf('Setting up subscription from remote %s to local %s', $oprofile->getUri(), $this->user->getNickname()));
             Subscription::start($oprofile->localProfile(),
                                 $this->user->getProfile());
         } else {
@@ -138,7 +137,7 @@ class UsersalmonAction extends SalmonAction
     {
         $oprofile = $this->ensureProfile();
         if ($oprofile) {
-            common_log(LOG_INFO, "Canceling subscription from remote {$oprofile->uri} to local {$this->user->nickname}");
+            common_log(LOG_INFO, sprintf('Canceling subscription from remote %s to local %s', $oprofile->getUri(), $this->user->getNickname()));
             Subscription::cancel($oprofile->localProfile(), $this->user->getProfile());
         } else {
             common_log(LOG_ERR, "Can't cancel subscription from remote, didn't find the profile");
index a7a77c6644c2d6d8076d8eaa87cc9f4280dbe03e..0a6abfa1bef239346fe4c30ae6d8da4943eb643b 100644 (file)
@@ -198,7 +198,7 @@ class FeedSub extends Managed_DataObject
     public function subscribe()
     {
         if ($this->sub_state && $this->sub_state != 'inactive') {
-            common_log(LOG_WARNING, "Attempting to (re)start PuSH subscription to {$this->uri} in unexpected state {$this->sub_state}");
+            common_log(LOG_WARNING, sprintf('Attempting to (re)start PuSH subscription to %s in unexpected state %s', $this->getUri(), $this->sub_state));
         }
 
         if (!Event::handle('FeedSubscribe', array($this))) {
@@ -235,7 +235,7 @@ class FeedSub extends Managed_DataObject
      */
     public function unsubscribe() {
         if ($this->sub_state != 'active') {
-            common_log(LOG_WARNING, "Attempting to (re)end PuSH subscription to {$this->uri} in unexpected state {$this->sub_state}");
+            common_log(LOG_WARNING, sprintf('Attempting to (re)end PuSH subscription to %s in unexpected state %s', $this->getUri(), $this->sub_state));
         }
 
         if (!Event::handle('FeedUnsubscribe', array($this))) {
@@ -278,10 +278,10 @@ class FeedSub extends Managed_DataObject
             Event::handle('FeedSubSubscriberCount', array($this, &$count));
 
             if ($count) {
-                common_log(LOG_INFO, __METHOD__ . ': ok, ' . $count . ' user(s) left for ' . $this->uri);
+                common_log(LOG_INFO, __METHOD__ . ': ok, ' . $count . ' user(s) left for ' . $this->getUri());
                 return false;
             } else {
-                common_log(LOG_INFO, __METHOD__ . ': unsubscribing, no users left for ' . $this->uri);
+                common_log(LOG_INFO, __METHOD__ . ': unsubscribing, no users left for ' . $this->getUri());
                 return $this->unsubscribe();
             }
         }
@@ -331,7 +331,7 @@ class FeedSub extends Managed_DataObject
                           'hub.verify_token' => 'Deprecated-since-PuSH-0.4', // TODO: rm!
 
                           'hub.secret' => $this->secret,
-                          'hub.topic' => $this->uri);
+                          'hub.topic' => $this->getUri());
             $client = new HTTPClient();
             if ($this->huburi) {
                 $hub = $this->huburi;
@@ -359,7 +359,7 @@ class FeedSub extends Managed_DataObject
             }
         } catch (Exception $e) {
             // wtf!
-            common_log(LOG_ERR, __METHOD__ . ": error \"{$e->getMessage()}\" hitting hub $this->huburi subscribing to $this->uri");
+            common_log(LOG_ERR, __METHOD__ . ": error \"{$e->getMessage()}\" hitting hub $this->huburi subscribing to " . $this->getUri());
 
             $orig = clone($this);
             $this->sub_state = 'inactive';
@@ -425,10 +425,10 @@ class FeedSub extends Managed_DataObject
      */
     public function receive($post, $hmac)
     {
-        common_log(LOG_INFO, __METHOD__ . ": packet for \"$this->uri\"! $hmac $post");
+        common_log(LOG_INFO, __METHOD__ . ": packet for \"" . $this->getUri() . "\"! $hmac $post");
 
         if ($this->sub_state != 'active') {
-            common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH for inactive feed $this->uri (in state '$this->sub_state')");
+            common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH for inactive feed " . $this->getUri() . " (in state '$this->sub_state')");
             return;
         }
 
@@ -483,9 +483,9 @@ class FeedSub extends Managed_DataObject
                     if ($tempfile) {
                         file_put_contents($tempfile, $post);
                     }
-                    common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bad SHA-1 HMAC: got $their_hmac, expected $our_hmac for feed $this->uri on $this->huburi; saved to $tempfile");
+                    common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bad SHA-1 HMAC: got $their_hmac, expected $our_hmac for feed " . $this->getUri() . " on $this->huburi; saved to $tempfile");
                 } else {
-                    common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bad SHA-1 HMAC: got $their_hmac, expected $our_hmac for feed $this->uri on $this->huburi");
+                    common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bad SHA-1 HMAC: got $their_hmac, expected $our_hmac for feed " . $this->getUri() . " on $this->huburi");
                 }
             } else {
                 common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bogus HMAC '$hmac'");
index b05d1755ca1250392b0c700e6dab6be7c603d187..59eccc52d06b7a6d778edfdd7e54618c3ed00663 100644 (file)
@@ -76,6 +76,11 @@ class Ostatus_profile extends Managed_DataObject
         );
     }
 
+    public function getUri()
+    {
+        return $this->uri;
+    }
+
     /**
      * Fetch the StatusNet-side profile for this feed
      * @return Profile
@@ -165,10 +170,10 @@ class Ostatus_profile extends Managed_DataObject
             return true;
         } else if ($this->group_id && ($this->profile_id || $this->peopletag_id)) {
             // TRANS: Server exception. %s is a URI
-            throw new ServerException(sprintf(_m('Invalid ostatus_profile state: Two or more IDs set for %s.'), $this->uri));
+            throw new ServerException(sprintf(_m('Invalid ostatus_profile state: Two or more IDs set for %s.'), $this->getUri()));
         } else {
             // TRANS: Server exception. %s is a URI
-            throw new ServerException(sprintf(_m('Invalid ostatus_profile state: All IDs empty for %s.'), $this->uri));
+            throw new ServerException(sprintf(_m('Invalid ostatus_profile state: All IDs empty for %s.'), $this->getUri()));
         }
     }
 
@@ -183,10 +188,10 @@ class Ostatus_profile extends Managed_DataObject
             return true;
         } else if ($this->peopletag_id && ($this->profile_id || $this->group_id)) {
             // TRANS: Server exception. %s is a URI
-            throw new ServerException(sprintf(_m('Invalid ostatus_profile state: Two or more IDs set for %s.'), $this->uri));
+            throw new ServerException(sprintf(_m('Invalid ostatus_profile state: Two or more IDs set for %s.'), $this->getUri()));
         } else {
             // TRANS: Server exception. %s is a URI
-            throw new ServerException(sprintf(_m('Invalid ostatus_profile state: All IDs empty for %s.'), $this->uri));
+            throw new ServerException(sprintf(_m('Invalid ostatus_profile state: All IDs empty for %s.'), $this->getUri()));
         }
     }
 
@@ -954,7 +959,7 @@ class Ostatus_profile extends Managed_DataObject
                     $groups[] = $oprofile->group_id;
                 } else {
                     // may be canonicalized or something
-                    $replies[] = $oprofile->uri;
+                    $replies[] = $oprofile->getUri();
                 }
                 continue;
             } catch (Exception $e) {
@@ -1227,7 +1232,7 @@ class Ostatus_profile extends Managed_DataObject
             throw new ServerException(sprintf(
                 // TRANS: Server exception. %s is a URI.
                 _m('Tried to update avatar for unsaved remote profile %s.'),
-                $this->uri));
+                $this->getUri()));
         }
 
         // @todo FIXME: This should be better encapsulated
@@ -1459,7 +1464,7 @@ class Ostatus_profile extends Managed_DataObject
         }
 
         $user = User::getKV('uri', $homeuri);
-        if ($user) {
+        if ($user instanceof User) {
             // TRANS: Exception.
             throw new Exception(_m('Local user cannot be referenced as remote.'));
         }
@@ -1914,7 +1919,7 @@ class Ostatus_profile extends Managed_DataObject
         $oprofile = Ostatus_profile::getKV('uri', 'acct:'.$addr);
 
         if ($oprofile instanceof Ostatus_profile) {
-            self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
+            self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->getUri());
             return $oprofile;
         }
 
@@ -1952,7 +1957,7 @@ class Ostatus_profile extends Managed_DataObject
             try {
                 common_log(LOG_INFO, "Discovery on acct:$addr with feed URL " . $hints['feedurl']);
                 $oprofile = self::ensureFeedURL($hints['feedurl'], $hints);
-                self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
+                self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->getUri());
                 return $oprofile;
             } catch (Exception $e) {
                 common_log(LOG_WARNING, "Failed creating profile from feed URL '$feedUrl': " . $e->getMessage());
@@ -1965,7 +1970,7 @@ class Ostatus_profile extends Managed_DataObject
             try {
                 common_log(LOG_INFO, "Discovery on acct:$addr with profile URL $profileUrl");
                 $oprofile = self::ensureProfileURL($hints['profileurl'], $hints);
-                self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
+                self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->getUri());
                 return $oprofile;
             } catch (OStatusShadowException $e) {
                 // We've ended up with a remote reference to a local user or group.
@@ -2029,7 +2034,7 @@ class Ostatus_profile extends Managed_DataObject
                 throw new Exception(sprintf(_m('Could not save OStatus profile for "%s".'),$addr));
             }
 
-            self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
+            self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->getUri());
             return $oprofile;
         }
 
@@ -2133,7 +2138,7 @@ class Ostatus_profile extends Managed_DataObject
                 // Groups can't post notices in StatusNet.
                 common_log(LOG_WARNING,
                     "OStatus: skipping post with group listed ".
-                    "as author: $oprofile->uri in feed from $this->uri");
+                    "as author: " . $oprofile->getUri() . " in feed from " . $this->getUri());
                 return false;
             }
         } else {
@@ -2141,7 +2146,7 @@ class Ostatus_profile extends Managed_DataObject
 
             if (empty($actor)) {
                 // OK here! assume the default
-            } else if ($actor->id == $this->uri || $actor->link == $this->uri) {
+            } else if ($actor->id == $this->getUri() || $actor->link == $this->getUri()) {
                 $this->updateFromActivityObject($actor);
             } else if ($actor->id) {
                 // We have an ActivityStreams actor with an explicit ID that doesn't match the feed owner.
@@ -2150,7 +2155,7 @@ class Ostatus_profile extends Managed_DataObject
                 // Most likely this is a plain ol' blog feed of some kind which
                 // doesn't match our expectations. We'll take the entry, but ignore
                 // the <author> info.
-                common_log(LOG_WARNING, "Got an actor '{$actor->title}' ({$actor->id}) on single-user feed for {$this->uri}");
+                common_log(LOG_WARNING, "Got an actor '{$actor->title}' ({$actor->id}) on single-user feed for " . $this->getUri());
             } else {
                 // Plain <author> without ActivityStreams actor info.
                 // We'll just ignore this info for now and save the update under the feed's identity.
index 45e2d8c0b0cff3e80c97ec4e52b0967460e63773..ffaae5588d1eae757e07e15ac654f27056d168fc 100644 (file)
@@ -47,7 +47,7 @@ $count = $user->N;
 echo "Found $count...\n";
 
 while ($user->fetch()) {
-    $uri = $user->uri;
+    $uri = $user->getUri();
     echo "user $user->id ($user->nickname) hidden by $uri";
     if ($dry) {
         echo " - skipping\n";
@@ -71,7 +71,7 @@ $count = $group->N;
 echo "Found $count...\n";
 
 while ($group->fetch()) {
-    $uri = $group->uri;
+    $uri = $group->getUri();
     echo "group $group->id ($group->nickname) hidden by $uri";
     if ($dry) {
         echo " - skipping\n";
@@ -106,7 +106,7 @@ $count = $group->N;
 echo "Found $count...\n";
 
 while ($group->fetch()) {
-    $uri = $group->uri;
+    $uri = $group->getUri();
     if (preg_match('!/group/(\d+)/id!', $uri, $matches)) {
         $id = intval($matches[1]);
         $local = Local_group::getKV('group_id', $id);
@@ -152,8 +152,8 @@ $count = $oprofile->N;
 echo "Found $count...\n";
 
 while ($oprofile->fetch()) {
-    $uri = $oprofile->uri;
-    if (preg_match('!/group/(\d+)/id!', $oprofile->uri, $matches)) {
+    $uri = $oprofile->getUri();
+    if (preg_match('!/group/(\d+)/id!', $oprofile->getUri(), $matches)) {
         $id = intval($matches[1]);
         $group = Local_group::getKV('group_id', $id);
         if ($group) {
index 4c4db6148aa59e9db9e429bc226b1d7458fb6d0d..c9f27cbde0ebe88f18032393a5ef28451cf90836 100644 (file)
@@ -81,7 +81,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
 
         $element = $this->_entryToElement($entry, false);
 
-        $this->assertEquals($notice->uri, ActivityUtils::childContent($element, 'id'));
+        $this->assertEquals($notice->getUri(), ActivityUtils::childContent($element, 'id'));
         $this->assertEquals($notice->content, ActivityUtils::childContent($element, 'title'));
         $this->assertEquals($notice->rendered, ActivityUtils::childContent($element, 'content'));
         $this->assertEquals(strtotime($notice->created), strtotime(ActivityUtils::childContent($element, 'published')));
@@ -210,8 +210,8 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
 
         $author = ActivityUtils::child($element, 'author');
 
-        $this->assertEquals($this->author1->nickname, ActivityUtils::childContent($author, 'name'));
-        $this->assertEquals($this->author1->uri, ActivityUtils::childContent($author, 'uri'));
+        $this->assertEquals($this->author1->getNickname(), ActivityUtils::childContent($author, 'name'));
+        $this->assertEquals($this->author1->getUri(), ActivityUtils::childContent($author, 'uri'));
     }
 
     /**
@@ -247,8 +247,8 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
         $irt = ActivityUtils::child($element, 'in-reply-to', 'http://purl.org/syndication/thread/1.0');
 
         $this->assertNotNull($irt);
-        $this->assertEquals($orig->uri, $irt->getAttribute('ref'));
-        $this->assertEquals($orig->bestUrl(), $irt->getAttribute('href'));
+        $this->assertEquals($orig->getUri(), $irt->getAttribute('ref'));
+        $this->assertEquals($orig->getUrl(), $irt->getAttribute('href'));
     }
 
     public function testReplyAttention()
@@ -263,7 +263,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
 
         $element = $this->_entryToElement($entry, true);
 
-        $this->assertEquals($this->targetUser1->uri, ActivityUtils::getLink($element, 'mentioned'));
+        $this->assertEquals($this->targetUser1->getUri(), ActivityUtils::getLink($element, 'mentioned'));
     }
 
     public function testMultipleReplyAttention()
@@ -292,8 +292,8 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
             $hrefs[] = $link->getAttribute('href');
         }
 
-        $this->assertTrue(in_array($this->targetUser1->uri, $hrefs));
-        $this->assertTrue(in_array($this->targetUser2->uri, $hrefs));
+        $this->assertTrue(in_array($this->targetUser1->getUri(), $hrefs));
+        $this->assertTrue(in_array($this->targetUser2->getUri(), $hrefs));
 
         $links = ActivityUtils::getLinks($element, 'mentioned');
 
@@ -305,8 +305,8 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
             $hrefs[] = $link->getAttribute('href');
         }
 
-        $this->assertTrue(in_array($this->targetUser1->uri, $hrefs));
-        $this->assertTrue(in_array($this->targetUser2->uri, $hrefs));
+        $this->assertTrue(in_array($this->targetUser1->getUri(), $hrefs));
+        $this->assertTrue(in_array($this->targetUser2->getUri(), $hrefs));
     }
 
     public function testGroupPostAttention()
@@ -319,7 +319,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
 
         $element = $this->_entryToElement($entry, true);
 
-        $this->assertEquals($this->targetGroup1->uri, ActivityUtils::getLink($element, 'mentioned'));
+        $this->assertEquals($this->targetGroup1->getUri(), ActivityUtils::getLink($element, 'mentioned'));
     }
 
     public function testMultipleGroupPostAttention()
@@ -342,8 +342,8 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
             $hrefs[] = $link->getAttribute('href');
         }
 
-        $this->assertTrue(in_array($this->targetGroup1->uri, $hrefs));
-        $this->assertTrue(in_array($this->targetGroup2->uri, $hrefs));
+        $this->assertTrue(in_array($this->targetGroup1->getUri(), $hrefs));
+        $this->assertTrue(in_array($this->targetGroup2->getUri(), $hrefs));
 
         $links = ActivityUtils::getLinks($element, 'mentioned');
 
@@ -355,8 +355,8 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
             $hrefs[] = $link->getAttribute('href');
         }
 
-        $this->assertTrue(in_array($this->targetGroup1->uri, $hrefs));
-        $this->assertTrue(in_array($this->targetGroup2->uri, $hrefs));
+        $this->assertTrue(in_array($this->targetGroup1->getUri(), $hrefs));
+        $this->assertTrue(in_array($this->targetGroup2->getUri(), $hrefs));
     }
 
     public function testRepeatLink()
@@ -371,7 +371,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
         $forward = ActivityUtils::child($element, 'forward', "http://ostatus.org/schema/1.0");
 
         $this->assertNotNull($forward);
-        $this->assertEquals($notice->uri, $forward->getAttribute('ref'));
+        $this->assertEquals($notice->getUri(), $forward->getAttribute('ref'));
         $this->assertEquals($notice->bestUrl(), $forward->getAttribute('href'));
     }