From: Mikael Nordfeldth Date: Thu, 4 Jun 2015 20:33:36 +0000 (+0200) Subject: Modernize File_redirection to use Managed_DataObject functions X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cafab14f2bdbd05c9047d53cc094ec483ee23e81;p=quix0rs-gnu-social.git Modernize File_redirection to use Managed_DataObject functions --- diff --git a/classes/File_redirection.php b/classes/File_redirection.php index 12619b0394..ea9db8e891 100644 --- a/classes/File_redirection.php +++ b/classes/File_redirection.php @@ -59,12 +59,7 @@ class File_redirection extends Managed_DataObject static public function getByUrl($url) { - $file = new File_redirection(); - $file->urlhash = File::hashurl($url); - if (!$file->find(true)) { - throw new NoResultException($file); - } - return $file; + return self::getByPK(array('urlhash' => File::hashurl($url))); } static function _commonHttp($url, $redirs) { @@ -261,7 +256,7 @@ class File_redirection extends Managed_DataObject // store it $file = File::getKV('url', $long_url); if ($file instanceof File) { - $file_id = $file->id; + $file_id = $file->getID(); } else { // Check if the target URL is itself a redirect... $redir_data = File_redirection::where($long_url); @@ -269,7 +264,7 @@ class File_redirection extends Managed_DataObject // We haven't seen the target URL before. // Save file and embedding data about it! $file = File::saveNew($redir_data, $long_url); - $file_id = $file->id; + $file_id = $file->getID(); } else if (is_string($redir_data)) { // The file is a known redirect target. $file = File::getKV('url', $redir_data); @@ -281,7 +276,7 @@ class File_redirection extends Managed_DataObject // SSL sites with cert issues. return null; } - $file_id = $file->id; + $file_id = $file->getID(); } } $file_redir = File_redirection::getKV('url', $short_url);