From e0e69ddd7cddba26811bfab6d7654df11e162015 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Fri, 18 Apr 2014 23:17:15 +0200 Subject: [PATCH] Throw exception when we can't get the url for a notice --- classes/Notice.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/classes/Notice.php b/classes/Notice.php index cdf6a20232..aadfc78cd0 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -213,7 +213,15 @@ class Notice extends Managed_DataObject public function getUrl() { // The risk is we start having empty urls and non-http uris... - return $this->url ?: $this->uri; + // and we can't really handle any other protocol right now. + switch (true) { + case common_valid_http_url($this->url): + return $this->url; + case common_valid_http_url($this->uri): + return $this->uri; + default: + throw new ServerException('No URL available for notice.'); + } } public function get_object_type($canonical=false) { -- 2.39.5