File::processNew can return -1 which was not true for empty()

Also, File->getEnclosure() now throws exception if not enough metadata.
This commit is contained in:
Mikael Nordfeldth
2014-06-02 01:26:23 +02:00
parent d596513e39
commit d6f52f5939
5 changed files with 26 additions and 21 deletions

View File

@@ -989,22 +989,23 @@ function common_linkify($url) {
$f = File::getKV('url', $longurl);
if (empty($f)) {
if (!$f instanceof File) {
if (common_config('attachments', 'process_links')) {
// XXX: this writes to the database. :<
$f = File::processNew($longurl);
}
}
if (!empty($f)) {
if ($f->getEnclosure()) {
if ($f instanceof File) {
try {
$enclosure = $f->getEnclosure();
$is_attachment = true;
$attachment_id = $f->id;
$thumb = File_thumbnail::getKV('file_id', $f->id);
if (!empty($thumb)) {
$has_thumb = true;
}
$has_thumb = ($thumb instanceof File_thumbnail);
} catch (ServerException $e) {
// There was not enough metadata available
}
}