]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/util.php
Merged
[quix0rs-gnu-social.git] / lib / util.php
index 62cd13af4a4231339c2b1b66e6be04616fcd5f10..1da9cc3c17551e091c55350726bb45e33f9a3d35 100644 (file)
@@ -321,7 +321,7 @@ function common_set_user($user)
         return false;
     }
 
-    if ($user) {
+    if ($user instanceof User) {
         if (Event::handle('StartSetUser', array(&$user))) {
             if (!empty($user)) {
                 if (!$user->hasRight(Right::WEBLOGIN)) {
@@ -538,7 +538,7 @@ function common_user_cache_hash($user=false)
     if ($user === false) {
         $user = common_current_user();
     }
-    if ($user) {
+    if ($user instanceof User) {
         return crc32($user->id . ':' . $user->nickname);
     } else {
         return '0';
@@ -681,15 +681,20 @@ function common_linkify_mention(array $mention)
     return $output;
 }
 
-function common_find_attentions($text, Profile $sender, Notice $parent=null)
+function common_get_attentions($text, Profile $sender, Notice $parent=null)
 {
     $mentions = common_find_mentions($text, $sender, $parent);
     $atts = array();
     foreach ($mentions as $mention) {
         foreach ($mention['mentioned'] as $mentioned) {
-            $atts[$mentioned->getUri()] = $mentioned->isGroup() ? ActivityObject::GROUP : ActivityObject::PERSON;
+            $atts[$mentioned->getUri()] = $mentioned->getObjectType();
         }
     }
+    if ($parent instanceof Notice) {
+        $parentAuthor = $parent->getProfile();
+        // afaik groups can't be authors
+        $atts[$parentAuthor->getUri()] = ActivityObject::PERSON;
+    }
     return $atts;
 }
 
@@ -2373,7 +2378,7 @@ function common_perf_counter($key, $val=null)
                 $_perfCounters[$key] = array($val);
             }
             if (common_config('site', 'logperf_detail')) {
-                common_log(LOG_DEBUG, "PERF COUNTER HIT: $key $val");
+                common_debug("PERF COUNTER HIT: $key $val");
             }
         }
     }
@@ -2387,14 +2392,14 @@ function common_log_perf_counters()
         if (isset($_startTime)) {
             $endTime = microtime(true);
             $diff = round(($endTime - $_startTime) * 1000);
-            common_log(LOG_DEBUG, "PERF runtime: ${diff}ms");
+            common_debug("PERF runtime: ${diff}ms");
         }
         $counters = $_perfCounters;
         ksort($counters);
         foreach ($counters as $key => $values) {
             $count = count($values);
             $unique = count(array_unique($values));
-            common_log(LOG_DEBUG, "PERF COUNTER: $key $count ($unique unique)");
+            common_debug("PERF COUNTER: $key $count ($unique unique)");
         }
     }
 }