From: Mikael Nordfeldth <mmn@hethane.se>
Date: Fri, 18 Apr 2014 21:36:01 +0000 (+0200)
Subject: Handle missing URIs and URLs better
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=85b022246f55c7e26190c77a1fab2b67ad4c317c;p=quix0rs-gnu-social.git

Handle missing URIs and URLs better
---

diff --git a/classes/Notice.php b/classes/Notice.php
index 56be89fb12..d9bdbc4498 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -424,6 +424,16 @@ class Notice extends Managed_DataObject
             $notice->created = common_sql_now();
         }
 
+        if (!$notice->isLocal()) {
+            // Only do these checks for non-local notices. Local notices will generate these values later.
+            if (!common_valid_http_url($url)) {
+                common_debug('Bad notice URL: ['.$url.'] Cannot link back to original!');
+            }
+            if (empty($uri)) {
+                throw new ServerException('No URI for remote notice. Cannot accept that.');
+            }
+        }
+
         $notice->content = $final;
 
         $notice->source = $source;
@@ -600,6 +610,11 @@ class Notice extends Managed_DataObject
                 $changed = true;
             }
 
+            if (empty($url)) {
+                $notice->url = common_local_url('shownotice', array('notice' => $notice->id), null, null, false);
+                $changed = true;
+            }
+
             // If it's not part of a conversation, it's
             // the beginning of a new conversation.