diff options
author | Brion Vibber <brion@pobox.com> | 2010-03-22 12:37:45 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-03-22 12:37:45 -0700 |
commit | 26f49de0dd5673584e734152d2d3329b90eb6978 (patch) | |
tree | 2ba00544c77cc3bfe0cafb4fa8fe60ce73d31d79 /lib | |
parent | c85228eadc60b50ed6e7c9cba596c3e66f5214b2 (diff) | |
parent | 27bfd1211d64298ee3c3b2d82d7b38ca1e1167ad (diff) |
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x
Conflicts:
lib/attachmentlist.php
Diffstat (limited to 'lib')
-rw-r--r-- | lib/attachmentlist.php | 24 | ||||
-rw-r--r-- | lib/servererroraction.php | 9 |
2 files changed, 27 insertions, 6 deletions
diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 13dafd13e..d29a5fa2f 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -304,7 +304,7 @@ class Attachment extends AttachmentListItem function showRepresentation() { if (empty($this->oembed->type)) { if (empty($this->attachment->mimetype)) { - $this->out->element('pre', null, 'oh well... not sure how to handle the following: ' . print_r($this->attachment, true)); + $this->showFallback(); } else { switch ($this->attachment->mimetype) { case 'image/gif': @@ -335,8 +335,12 @@ class Attachment extends AttachmentListItem if ($this->attachment->filename) { // Locally-uploaded HTML. Scrub and display inline. $this->showHtmlFile($this->attachment); + break; } - break; + // Fall through to default + + default: + $this->showFallback(); } } } else { @@ -359,7 +363,7 @@ class Attachment extends AttachmentListItem break; default: - $this->out->element('pre', null, 'oh well... not sure how to handle the following oembed: ' . print_r($this->oembed, true)); + $this->showFallback(); } } } @@ -416,5 +420,19 @@ class Attachment extends AttachmentListItem return $scrubbed; } + + function showFallback() + { + // If we don't know how to display an attachment inline, we probably + // shouldn't have gotten to this point. + // + // But, here we are... displaying details on a file or remote URL + // either on the main view or in an ajax-loaded lightbox. As a lesser + // of several evils, we'll try redirecting to the actual target via + // client-side JS. + + common_log(LOG_ERR, "Empty or unknown type for file id {$this->attachment->id}; falling back to client-side redirect."); + $this->out->raw('<script>window.location = ' . json_encode($this->attachment->url) . ';</script>'); + } } diff --git a/lib/servererroraction.php b/lib/servererroraction.php index 0993a63bc..9b5a553dc 100644 --- a/lib/servererroraction.php +++ b/lib/servererroraction.php @@ -62,15 +62,18 @@ class ServerErrorAction extends ErrorAction 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported'); - function __construct($message='Error', $code=500) + function __construct($message='Error', $code=500, $ex=null) { parent::__construct($message, $code); $this->default = 500; // Server errors must be logged. - - common_log(LOG_ERR, "ServerErrorAction: $code $message"); + $log = "ServerErrorAction: $code $message"; + if ($ex) { + $log .= "\n" . $ex->getTraceAsString(); + } + common_log(LOG_ERR, $log); } // XXX: Should these error actions even be invokable via URI? |