]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/util.php
Merge branch 'at-mention-url' into 'master'
[quix0rs-gnu-social.git] / lib / util.php
index 8eb44c372a7756316b290ddf48d57513a1a80c62..1844240f455497e15ee7150d7f38bee46933e798 100644 (file)
@@ -725,6 +725,8 @@ function common_find_mentions($text, Notice $notice)
             }
         } catch (NoParentNoticeException $e) {
             // It wasn't a reply to anything, so we can't harvest nickname-relations.
+        } catch (NoResultException $e) {
+            // The parent notice was deleted.
         }
 
         $matches = common_find_mentions_raw($text);
@@ -787,7 +789,7 @@ function common_find_mentions($text, Notice $notice)
             $tagged = $sender->getTaggedSubscribers($tag);
 
             $url = common_local_url('showprofiletag',
-                                    array('tagger' => $sender->nickname,
+                                    array('nickname' => $sender->getNickname(),
                                           'tag' => $tag));
 
             $mentions[] = array('mentioned' => $tagged,
@@ -988,20 +990,9 @@ function common_linkify($url) {
         $canon = "mailto:$url";
         $longurl = "mailto:$url";
     } else {
-
         $canon = File_redirection::_canonUrl($url);
-
         $longurl_data = File_redirection::where($canon, common_config('attachments', 'process_links'));
-        if (is_array($longurl_data)) {
-            $longurl = $longurl_data['url'];
-        } elseif (is_string($longurl_data)) {
-            $longurl = $longurl_data;
-        } else {
-            // Unable to reach the server to verify contents, etc
-            // Just pass the link on through for now.
-            common_log(LOG_ERR, "Can't linkify url '$url'");
-            $longurl = $url;
-        }
+        $longurl = $longurl_data->url;
     }
 
     $attrs = array('href' => $canon, 'title' => $longurl);
@@ -1558,14 +1549,24 @@ function common_root_url($ssl=false)
 }
 
 /**
- * returns $bytes bytes of random data as a hexadecimal string
+ * returns $bytes bytes of raw random data
  */
-function common_random_hexstr($bytes)
+function common_random_rawstr($bytes)
 {
-    $str = @file_exists('/dev/urandom')
+    $rawstr = @file_exists('/dev/urandom')
             ? common_urandom($bytes)
             : common_mtrand($bytes);
 
+    return $rawstr;
+}
+
+/**
+ * returns $bytes bytes of random data as a hexadecimal string
+ */
+function common_random_hexstr($bytes)
+{
+    $str = common_random_rawstr($bytes);
+
     $hexstr = '';
     for ($i = 0; $i < $bytes; $i++) {
         $hexstr .= sprintf("%02x", ord($str[$i]));
@@ -1869,6 +1870,7 @@ function common_get_mime_media($type)
     return strtolower($tmp[0]);
 }
 
+// Get only the mimetype and not additional info (separated from bare mime with semi-colon)
 function common_bare_mime($mimetype)
 {
     $mimetype = mb_strtolower($mimetype);