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

Commit fd62f6b9 authored by Zach Copley's avatar Zach Copley

Don't throw exception if bookmark has no attachments; log error and render as...

Don't throw exception if bookmark has no attachments; log error and render as normal notice instead.
parent ba4bda9b
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Copyright (C) 2011, StatusNet, Inc. * Copyright (C) 2011, StatusNet, Inc.
* *
* Adapter to show bookmarks in a nicer way * Adapter to show bookmarks in a nicer way
* *
* PHP version 5 * PHP version 5
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
...@@ -68,22 +68,33 @@ class BookmarkListItem extends NoticeListItemAdapter ...@@ -68,22 +68,33 @@ class BookmarkListItem extends NoticeListItemAdapter
$atts = $notice->attachments(); $atts = $notice->attachments();
if (count($atts) < 1) { if (empty($atts)) {
// Something wrong; let default code deal with it.
// TRANS: Exception thrown when a bookmark has no attachments. // Something went wrong!
// TRANS: %1$s is a bookmark ID, %2$s is a notice ID (number).
throw new Exception(sprintf(_m('Bookmark %1$s (notice %2$d) has no attachments.'), common_log(
$nb->id, LOG_ERR,
$notice->id)); sprintf(
_m('Bookmark %1$s (notice %2$d) has no attachments.'),
$nb->id,
$notice->id
)
);
// try to show the notice as plain text
parent::showContent();
return;
} }
$att = $atts[0]; $att = $atts[0];
$out->elementStart('h3'); $out->elementStart('h3');
$out->element('a', $out->element('a',
array('href' => $att->url, array('href' => $att->url,
'class' => 'bookmark-title'), 'class' => 'bookmark-title'),
$nb->title); $nb->title);
$out->elementEnd('h3'); $out->elementEnd('h3');
// Replies look like "for:" tags // Replies look like "for:" tags
......
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