From 93377e1c24103bcb1e95f05b610143ada9c9b6ba Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Fri, 23 Jan 2015 12:39:08 +0100 Subject: [PATCH] Allow fallback to local URL on Notice->getUrl() To avoid verbose exception handling in other parts of the code. --- classes/Notice.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index e15b6cbcb4..641b129552 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -276,8 +276,10 @@ class Notice extends Managed_DataObject /* * Get the original representation URL of this notice. + * + * @param boolean $fallback Whether to fall back to generate a local URL or throw InvalidUrlException */ - public function getUrl() + public function getUrl($fallback=false) { // The risk is we start having empty urls and non-http uris... // and we can't really handle any other protocol right now. @@ -286,7 +288,7 @@ class Notice extends Managed_DataObject return $this->url; case !$this->isLocal() && common_valid_http_url($this->uri): // Sometimes we only have the URI for remote posts. return $this->uri; - case $this->isLocal(): + case $this->isLocal() || $fallback: // let's generate a valid link to our locally available notice on demand return common_local_url('shownotice', array('notice' => $this->id), null, null, false); default: -- 2.39.5