From: Mikael Nordfeldth Date: Fri, 23 Jan 2015 11:39:08 +0000 (+0100) Subject: Allow fallback to local URL on Notice->getUrl() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=93377e1c24103bcb1e95f05b610143ada9c9b6ba;p=quix0rs-gnu-social.git Allow fallback to local URL on Notice->getUrl() To avoid verbose exception handling in other parts of the code. --- 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: