diff --git a/CHANGELOG.md b/CHANGELOG.md index af53b6c95..c2996b161 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# v1.1.17 +## 02/17/2017 + +1. [](#bugfix) + * Fix for double extensions getting added during some redirects [#1307](https://github.com/getgrav/grav/issues/1307) + * Fix syntax error in PHP 5.3. Move the version check before requiring the autoloaded deps + * Fix Whoops displaying error page if there is PHP core warning or error [Admin #980](https://github.com/getgrav/grav-plugin-admin/issues/980) + # v1.1.16 ## 02/10/2017 diff --git a/README.md b/README.md index ef5a74569..901544c86 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ Support us with a monthly donation and help us continue our activities. [[Become # Sponsors Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/grav#sponsor)] + diff --git a/index.php b/index.php index 8d8d2b62f..b7a100134 100644 --- a/index.php +++ b/index.php @@ -7,6 +7,7 @@ */ namespace Grav; +define('GRAV_PHP_MIN', '5.5.9'); // Ensure vendor libraries exist $autoload = __DIR__ . '/vendor/autoload.php'; @@ -23,13 +24,13 @@ if (PHP_SAPI == 'cli-server') { use Grav\Common\Grav; use RocketTheme\Toolbox\Event\Event; -// Register the auto-loader. -$loader = require_once $autoload; - if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) { die(sprintf('You are running PHP %s, but Grav needs at least PHP %s to run.', $ver, $req)); } +// Register the auto-loader. +$loader = require_once $autoload; + // Set timezone to default, falls back to system if php.ini not set date_default_timezone_set(@date_default_timezone_get()); @@ -50,6 +51,6 @@ $grav = Grav::instance( try { $grav->process(); } catch (\Exception $e) { - $grav->fireEvent('onFatalException', new Event(['exception' => $e])); + $grav->fireEvent('onFatalException', new Event(array('exception' => $e))); throw $e; } diff --git a/system/defines.php b/system/defines.php index d033a98d8..387435b35 100644 --- a/system/defines.php +++ b/system/defines.php @@ -8,10 +8,13 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.1.16'); +define('GRAV_VERSION', '1.1.17'); define('GRAV_TESTING', false); define('DS', '/'); -define('GRAV_PHP_MIN', '5.5.9'); + +if (!defined('GRAV_PHP_MIN')) { + define('GRAV_PHP_MIN', '5.5.9'); +} // Directories and Paths if (!defined('GRAV_ROOT')) { diff --git a/system/src/Grav/Common/Errors/Errors.php b/system/src/Grav/Common/Errors/Errors.php index 49c79e452..b073f756f 100644 --- a/system/src/Grav/Common/Errors/Errors.php +++ b/system/src/Grav/Common/Errors/Errors.php @@ -20,7 +20,8 @@ class Errors $jsonRequest = $_SERVER && isset($_SERVER['HTTP_ACCEPT']) && $_SERVER['HTTP_ACCEPT'] == 'application/json'; // Setup Whoops-based error handler - $whoops = new \Whoops\Run; + $system = new SystemFacade; + $whoops = new \Whoops\Run($system); $verbosity = 1; diff --git a/system/src/Grav/Common/Errors/SystemFacade.php b/system/src/Grav/Common/Errors/SystemFacade.php new file mode 100644 index 000000000..3170a1233 --- /dev/null +++ b/system/src/Grav/Common/Errors/SystemFacade.php @@ -0,0 +1,39 @@ +whoopsShutdownHandler = $function; + register_shutdown_function([$this, 'handleShutdown']); + } + + /** + * Special case to deal with Fatal errors and the like. + */ + public function handleShutdown() + { + $error = $this->getLastError(); + + // Ignore core warnings and errors. + if ($error && !($error['type'] & (E_CORE_WARNING | E_CORE_ERROR))) { + $handler = $this->whoopsShutdownHandler; + $handler(); + } + } +} diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index f8fb702c7..4e8614aec 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -345,9 +345,10 @@ class Pages $page = $this->dispatch($route, $all); } else { // Try Regex style redirects + $uri = $this->grav['uri']; $source_url = $url; - $extension = $this->grav['uri']->extension(); - if (isset($extension)) { + $extension = $uri->extension(); + if (isset($extension) && !Utils::endsWith($uri->url(), $extension)) { $source_url.= '.' . $extension; }