From dcffe5d992979a7ecd5ff7a83e8de3ececfb1b89 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Tue, 29 Mar 2016 12:13:53 +0200 Subject: [PATCH] Forgotten File::getByUrl conversations (performance++) --- lib/action.php | 12 ++++++++---- plugins/Oembed/classes/File_oembed.php | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/action.php b/lib/action.php index 6d6efb1cbc..86b4908b3d 100644 --- a/lib/action.php +++ b/lib/action.php @@ -661,10 +661,14 @@ class Action extends HTMLOutputter // lawsuit // if logo is an uploaded file, try to fall back to HTTPS file URL $httpUrl = common_config('site', 'logo'); if (!empty($httpUrl)) { - $f = File::getKV('url', $httpUrl); - if (!empty($f) && !empty($f->filename)) { - // this will handle the HTTPS case - $logoUrl = File::url($f->filename); + try { + $f = File::getByUrl('url', $httpUrl); + if (!empty($f->filename)) { + // this will handle the HTTPS case + $logoUrl = File::url($f->filename); + } + } catch (NoResultException $e) { + // no match } } } diff --git a/plugins/Oembed/classes/File_oembed.php b/plugins/Oembed/classes/File_oembed.php index 246a74fea0..95aa91ff4c 100644 --- a/plugins/Oembed/classes/File_oembed.php +++ b/plugins/Oembed/classes/File_oembed.php @@ -120,10 +120,10 @@ class File_oembed extends Managed_DataObject $file_oembed->url = $data->url; $given_url = File_redirection::_canonUrl($file_oembed->url); if (! empty($given_url)){ - $file = File::getKV('url', $given_url); - if ($file instanceof File) { + try { + $file = File::getByUrl($given_url); $file_oembed->mimetype = $file->mimetype; - } else { + } catch (NoResultException $e) { $redir = File_redirection::where($given_url); if (empty($redir->file_id)) { $f = $redir->getFile(); -- 2.39.5