]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/File_redirection.php
Merge branch 'master' into mmn_fixes
[quix0rs-gnu-social.git] / classes / File_redirection.php
index 8ce715e699b843ae02fa24b8756bd6273956591f..d1b266c90b4a89f96625ece8e3b81084040519b0 100644 (file)
@@ -120,6 +120,8 @@ class File_redirection extends Managed_DataObject
                 // no content it'll be cheap. :)
                 $request = self::_commonHttp($short_url, $redirs);
                 $response = $request->send();
+            } elseif (400 == $response->getStatus()) {
+                throw new Exception('Got error 400 on HEAD request, will not go further.');
             }
         } catch (Exception $e) {
             // Invalid URL or failure to reach server
@@ -171,12 +173,11 @@ class File_redirection extends Managed_DataObject
         try {
             $r = File_redirection::getByUrl($in_url);
 
-            $f = File::getKV('id',$r->file_id);
-
-            if($file instanceof File) {
+            try {
+                $f = File::getByID($r->file_id);
                 $r->file = $f;
-                $r->redir_url = $f->url;            
-            } else {
+                $r->redir_url = $f->url;
+            } catch (NoResultException $e) {
                 // Invalid entry, delete and run again
                 common_log(LOG_ERR, "Could not find File with id=".$r->file_id." referenced in File_redirection, deleting File redirection entry and and trying again...");                 
                 $r->delete();
@@ -368,6 +369,11 @@ class File_redirection extends Managed_DataObject
                 // don't touch anything
                 break;
 
+            // URLs with coordinates, not browsable domain names
+            case 'geo':
+                // don't touch anything
+                break;
+
             default:
                 $out_url = $default_scheme . ltrim($out_url, '/');
                 $p = parse_url($out_url);
@@ -445,4 +451,4 @@ class File_redirection extends Managed_DataObject
 
         return $this->file;
     }
-}
\ No newline at end of file
+}