Forgotten File::getByUrl conversations (performance++)

This commit is contained in:
Mikael Nordfeldth 2016-03-29 12:13:53 +02:00
parent 4e2be07234
commit dcffe5d992
2 changed files with 11 additions and 7 deletions

View File

@ -661,11 +661,15 @@ class Action extends HTMLOutputter // lawsuit
// if logo is an uploaded file, try to fall back to HTTPS file URL // if logo is an uploaded file, try to fall back to HTTPS file URL
$httpUrl = common_config('site', 'logo'); $httpUrl = common_config('site', 'logo');
if (!empty($httpUrl)) { if (!empty($httpUrl)) {
$f = File::getKV('url', $httpUrl); try {
if (!empty($f) && !empty($f->filename)) { $f = File::getByUrl('url', $httpUrl);
if (!empty($f->filename)) {
// this will handle the HTTPS case // this will handle the HTTPS case
$logoUrl = File::url($f->filename); $logoUrl = File::url($f->filename);
} }
} catch (NoResultException $e) {
// no match
}
} }
} }
} else { } else {

View File

@ -120,10 +120,10 @@ class File_oembed extends Managed_DataObject
$file_oembed->url = $data->url; $file_oembed->url = $data->url;
$given_url = File_redirection::_canonUrl($file_oembed->url); $given_url = File_redirection::_canonUrl($file_oembed->url);
if (! empty($given_url)){ if (! empty($given_url)){
$file = File::getKV('url', $given_url); try {
if ($file instanceof File) { $file = File::getByUrl($given_url);
$file_oembed->mimetype = $file->mimetype; $file_oembed->mimetype = $file->mimetype;
} else { } catch (NoResultException $e) {
$redir = File_redirection::where($given_url); $redir = File_redirection::where($given_url);
if (empty($redir->file_id)) { if (empty($redir->file_id)) {
$f = $redir->getFile(); $f = $redir->getFile();