diff --git a/index.php b/index.php index 1f616528..cc40dda1 100644 --- a/index.php +++ b/index.php @@ -18,11 +18,11 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ // Set this to true to disable demo/debugging controllers -define("IN_PRODUCTION", true); +define("IN_PRODUCTION", false); -// Gallery requires PHP 5.2+ -version_compare(PHP_VERSION, "5.2.3", "<") and - exit("Gallery requires PHP 5.2.3 or newer (you're using " . PHP_VERSION . ")"); +// Remove this if you want, things should probably work, but you've been warned. +version_compare(PHP_VERSION, "7.0.0", "<") and + exit("Gallery requires PHP 7.0.0 or newer (you're using " . PHP_VERSION . ")"); // Gallery is not supported on Windows. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { @@ -91,7 +91,9 @@ if (PHP_SAPI == "cli") { @mkdir("test/var", 0777, true); @mkdir("test/var/logs", 0777, true); } - @copy("var/database.php", "test/var/database.php"); + if (!file_exists("test/var/database.php")) { + @copy("var/database.php", "test/var/database.php"); + } define("VARPATH", realpath("test/var") . "/"); break; diff --git a/modules/gallery/helpers/MY_num.php b/modules/gallery/helpers/MY_num.php index ed6b49bf..d9e414e5 100644 --- a/modules/gallery/helpers/MY_num.php +++ b/modules/gallery/helpers/MY_num.php @@ -50,6 +50,7 @@ class num extends num_Core { foreach (array("G" => 1e9, "M" => 1e6, "K" => 1e3) as $k => $v) { if ($num > $v) { $num = round($num / $v) . $k; + break; } } return $num; diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index 0e190e46..0e0c0203 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -457,6 +457,8 @@ class module_Core { if (empty(self::$var_cache)) { self::$var_cache = Cache::instance()->get("var_cache"); if (empty(self::$var_cache)) { + self::$var_cache = new stdClass(); + // Cache doesn't exist, create it now. foreach (db::build() ->select("module_name", "name", "value") @@ -464,8 +466,11 @@ class module_Core { ->order_by("module_name") ->order_by("name") ->execute() as $row) { + if (!isset(self::$var_cache->{$row->module_name})) { + self::$var_cache->{$row->module_name} = new stdClass(); + } // Mute the "Creating default object from empty value" warning below - @self::$var_cache->{$row->module_name}->{$row->name} = $row->value; + self::$var_cache->{$row->module_name}->{$row->name} = $row->value; } Cache::instance()->set("var_cache", self::$var_cache, array("vars")); } diff --git a/modules/gallery/libraries/MY_Kohana_Exception.php b/modules/gallery/libraries/MY_Kohana_Exception.php index 51490a6c..21c1583c 100644 --- a/modules/gallery/libraries/MY_Kohana_Exception.php +++ b/modules/gallery/libraries/MY_Kohana_Exception.php @@ -52,7 +52,7 @@ class Kohana_Exception extends Kohana_Exception_Core { * Elides sensitive data which shouldn't be echoed to the client, * such as passwords, and other secrets. */ - /* Visible for testing*/ static function _sanitize_for_dump($value, $key=null, $max_level) { + /* Visible for testing*/ static function _sanitize_for_dump($value, $key, $max_level) { // Better elide too much than letting something through. // Note: unanchored match is intended. if (!$max_level) { @@ -98,4 +98,4 @@ class Kohana_Exception extends Kohana_Exception_Core { public static function debug_path($file) { return html::clean(parent::debug_path($file)); } -} \ No newline at end of file +} diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php index b04a1e92..9e283105 100644 --- a/modules/gallery/tests/File_Structure_Test.php +++ b/modules/gallery/tests/File_Structure_Test.php @@ -25,7 +25,7 @@ class File_Structure_Test extends Gallery_Unit_Test_Case { new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT))); $count = 0; foreach ($dir as $file) { - if (preg_match("/vendor/", $file)) continue; + if (preg_match("#(vendor|test)/#", $file)) continue; $count++; if (!preg_match("|\.html\.php$|", $file->getPathname())) { @@ -59,7 +59,7 @@ class File_Structure_Test extends Gallery_Unit_Test_Case { $dir = new GalleryCodeFilterIterator( new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT))); foreach ($dir as $file) { - if (preg_match("/vendor/", $file)) { + if (preg_match("#(vendor|test)/#", $file)) { continue; } elseif (preg_match("/\.(php|css|html|js)$/", $file)) { foreach (file($file) as $line) { @@ -190,7 +190,7 @@ class File_Structure_Test extends Gallery_Unit_Test_Case { break; default: - if (preg_match("/vendor/", $path)) { + if (preg_match("#(vendor|test)/#", $path)) { # including unmodified 3rd party code } elseif (preg_match("/modules\/(autorotate|movie_resized)/", $path)) { # including unmodified 3rd party code @@ -335,7 +335,7 @@ class File_Structure_Test extends Gallery_Unit_Test_Case { new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT))); $errors = ""; foreach ($dir as $file) { - if (preg_match("/vendor/", $file)) { + if (preg_match("#(vendor|test)/#", $file)) { continue; } elseif (preg_match("/\.(php|css|html|js)$/", $file)) { foreach (file($file) as $line_num => $line) { diff --git a/modules/gallery_unit_test/controllers/gallery_unit_test.php b/modules/gallery_unit_test/controllers/gallery_unit_test.php index 8f19bd92..14e364ff 100644 --- a/modules/gallery_unit_test/controllers/gallery_unit_test.php +++ b/modules/gallery_unit_test/controllers/gallery_unit_test.php @@ -42,7 +42,7 @@ class Gallery_Unit_Test_Controller extends Controller { print "Please copy kohana/config/database.php to $original_config.\n"; return; } else { - copy($original_config, $test_config); + if (!file_exists($test_config)) copy($original_config, $test_config); $db_config = Kohana::config('database'); if (empty($db_config['unit_test'])) { $default = $db_config['default']; @@ -93,7 +93,7 @@ class Gallery_Unit_Test_Controller extends Controller { // Clean out the filesystem. Note that this cleans out test/var/database.php, but that's ok // because we technically don't need it anymore. If this is confusing, we could always // arrange to preserve that one file. - @system("rm -rf test/var"); + @system("rm -rf test/var/albums test/var/modules test/var/resizes test/var/thumbs test/var/tmp test/var/uploads"); @mkdir('test/var/logs', 0777, true); $active_modules = module::$active;