We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 93377e1c authored by mattl's avatar mattl

Allow fallback to local URL on Notice->getUrl()

To avoid verbose exception handling in other parts of the code.
parent 3119341a
......@@ -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);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment