Mediafile updated to insert urlhash and lookup properly

This commit is contained in:
Mikael Nordfeldth 2015-02-19 19:12:16 +01:00
parent c05e9b118c
commit 5b940f255f
1 changed files with 4 additions and 3 deletions

View File

@ -141,10 +141,11 @@ class MediaFile
function maybeAddRedir($file_id, $url)
{
$file_redir = File_redirection::getKV('url', $url);
if (!$file_redir instanceof File_redirection) {
try {
$file_redir = File_redirection::getByUrl($url);
} catch (NoResultException $e) {
$file_redir = new File_redirection;
$file_redir->urlhash = File::hashurl($url);
$file_redir->url = $url;
$file_redir->file_id = $file_id;