Modernize File_redirection to use Managed_DataObject functions
This commit is contained in:
parent
63251fb9d0
commit
cafab14f2b
|
@ -59,12 +59,7 @@ class File_redirection extends Managed_DataObject
|
||||||
|
|
||||||
static public function getByUrl($url)
|
static public function getByUrl($url)
|
||||||
{
|
{
|
||||||
$file = new File_redirection();
|
return self::getByPK(array('urlhash' => File::hashurl($url)));
|
||||||
$file->urlhash = File::hashurl($url);
|
|
||||||
if (!$file->find(true)) {
|
|
||||||
throw new NoResultException($file);
|
|
||||||
}
|
|
||||||
return $file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function _commonHttp($url, $redirs) {
|
static function _commonHttp($url, $redirs) {
|
||||||
|
@ -261,7 +256,7 @@ class File_redirection extends Managed_DataObject
|
||||||
// store it
|
// store it
|
||||||
$file = File::getKV('url', $long_url);
|
$file = File::getKV('url', $long_url);
|
||||||
if ($file instanceof File) {
|
if ($file instanceof File) {
|
||||||
$file_id = $file->id;
|
$file_id = $file->getID();
|
||||||
} else {
|
} else {
|
||||||
// Check if the target URL is itself a redirect...
|
// Check if the target URL is itself a redirect...
|
||||||
$redir_data = File_redirection::where($long_url);
|
$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.
|
// We haven't seen the target URL before.
|
||||||
// Save file and embedding data about it!
|
// Save file and embedding data about it!
|
||||||
$file = File::saveNew($redir_data, $long_url);
|
$file = File::saveNew($redir_data, $long_url);
|
||||||
$file_id = $file->id;
|
$file_id = $file->getID();
|
||||||
} else if (is_string($redir_data)) {
|
} else if (is_string($redir_data)) {
|
||||||
// The file is a known redirect target.
|
// The file is a known redirect target.
|
||||||
$file = File::getKV('url', $redir_data);
|
$file = File::getKV('url', $redir_data);
|
||||||
|
@ -281,7 +276,7 @@ class File_redirection extends Managed_DataObject
|
||||||
// SSL sites with cert issues.
|
// SSL sites with cert issues.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$file_id = $file->id;
|
$file_id = $file->getID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$file_redir = File_redirection::getKV('url', $short_url);
|
$file_redir = File_redirection::getKV('url', $short_url);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user