]> git.mxchange.org Git - friendica.git/commitdiff
Improve test behaviour
authorMichael <heluecht@pirati.ca>
Sun, 8 Jul 2018 05:29:06 +0000 (05:29 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 8 Jul 2018 05:29:06 +0000 (05:29 +0000)
include/dba.php
src/App.php
src/Object/Image.php

index 061f5399c76d11b38bdb72c1a9a7ec60b2b11e40..b95589970edd5f3c48e91a12051de29174d311bd 100644 (file)
@@ -955,6 +955,8 @@ class dba {
         * @return boolean Was the command executed successfully?
         */
        public static function rollback() {
+               $ret = false;
+
                switch (self::$driver) {
                        case 'pdo':
                                if (!self::$db->inTransaction()) {
index 92ff0571387cbd928f293698ef6acf88535ac703..a2bdd03df6c1801f1836f8edb5f9fd68eb883adc 100644 (file)
@@ -412,11 +412,17 @@ class App
        public function set_baseurl($url)
        {
                $parsed = @parse_url($url);
+               $hostname = '';
 
                if (x($parsed)) {
-                       $this->scheme = $parsed['scheme'];
+                       if (!empty($parsed['scheme'])) {
+                               $this->scheme = $parsed['scheme'];
+                       }
+
+                       if (!empty($parsed['host'])) {
+                               $hostname = $parsed['host'];
+                       }
 
-                       $hostname = $parsed['host'];
                        if (x($parsed, 'port')) {
                                $hostname .= ':' . $parsed['port'];
                        }
@@ -432,7 +438,7 @@ class App
                                $this->hostname = Config::get('config', 'hostname');
                        }
 
-                       if (!isset($this->hostname) || ( $this->hostname == '')) {
+                       if (!isset($this->hostname) || ($this->hostname == '')) {
                                $this->hostname = $hostname;
                        }
                }
index 9621badaba98e706429568faef54243fb83a9d5b..7e6b758f1cb559d564f2ff917535846453fa4fb3 100644 (file)
@@ -781,22 +781,23 @@ class Image
                        $img_str = Network::fetchUrl($url, true, $redirects, 4);
                        $filesize = strlen($img_str);
 
-                       // The tests are failing with an read error. This can be caused by memory shortage
-                       // See https://stackoverflow.com/questions/10175758/getimagesize-read-error
-                       // So we use the alternate method instead
-                       //if (function_exists("getimagesizefromstring")) {
-                       //      $data = getimagesizefromstring($img_str);
-                       //} else {
-                               $tempfile = tempnam(get_temppath(), "cache");
-
-                               $a = get_app();
-                               $stamp1 = microtime(true);
-                               file_put_contents($tempfile, $img_str);
-                               $a->save_timestamp($stamp1, "file");
-
-                               $data = getimagesize($tempfile);
-                               unlink($tempfile);
-                       //}
+                       try {
+                               if (function_exists("getimagesizefromstring")) {
+                                       $data = getimagesizefromstring($img_str);
+                               } else {
+                                       $tempfile = tempnam(get_temppath(), "cache");
+
+                                       $a = get_app();
+                                       $stamp1 = microtime(true);
+                                       file_put_contents($tempfile, $img_str);
+                                       $a->save_timestamp($stamp1, "file");
+
+                                       $data = getimagesize($tempfile);
+                                       unlink($tempfile);
+                               }
+                       } catch (Exception $e) {
+                               return false;
+                       }
 
                        if ($data) {
                                $data["size"] = $filesize;