From f65633043a1e20fefa63eb2f394312fd05055efb Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sat, 24 Oct 2015 12:18:54 -0600 Subject: [PATCH 01/13] Added CSS Group asset support #374 --- CHANGELOG.md | 10 +++++ system/src/Grav/Common/Assets.php | 70 +++++++++++++++++++------------ 2 files changed, 53 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cb97d31d..78b7c9416 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# v1.0.0-rc.2 +## xx/xx/2015 + +1. [](#new) + * Added support for CSS Asset groups +1. [](#improved) + * ... +1. [](#bugfix) + * ... + # v1.0.0-rc.1 ## 10/23/2015 diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index 14a9161ef..e2f39d2e5 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -227,21 +227,22 @@ class Assets * It checks for duplicates. * You may add more than one asset passing an array as argument. * - * @param mixed $asset - * @param int $priority the priority, bigger comes first - * @param bool $pipeline false if this should not be pipelined + * @param mixed $asset + * @param int $priority the priority, bigger comes first + * @param bool $pipeline false if this should not be pipelined + * @param null $group * * @return $this */ - public function addCss($asset, $priority = null, $pipeline = null) + public function addCss($asset, $priority = null, $pipeline = null, $group = null) { if (is_array($asset)) { foreach ($asset as $a) { - $this->addCss($a, $priority, $pipeline); + $this->addCss($a, $priority, $pipeline, $group); } return $this; } elseif (isset($this->collections[$asset])) { - $this->add($this->collections[$asset], $priority, $pipeline); + $this->add($this->collections[$asset], $priority, $pipeline, $group); return $this; } @@ -253,7 +254,8 @@ class Assets 'asset' => $asset, 'priority' => intval($priority ?: 10), 'order' => count($this->css), - 'pipeline' => $pipeline ?: true + 'pipeline' => $pipeline ?: true, + 'group' => $group ?: 'head' ]; // check for dynamic array and merge with defaults @@ -369,11 +371,12 @@ class Assets * For adding chunks of string-based inline CSS * * @param mixed $asset - * @param int $priority the priority, bigger comes first + * @param int $priority the priority, bigger comes first + * @param null $group * * @return $this */ - public function addInlineCss($asset, $priority = null) + public function addInlineCss($asset, $priority = null, $group = null) { if (is_a($asset, 'Twig_Markup')) { $asset = strip_tags((string)$asset); @@ -382,7 +385,8 @@ class Assets $data = [ 'priority' => intval($priority ?: 10), 'order' => count($this->inline_css), - 'asset' => $asset + 'asset' => $asset, + 'group' => $group ?: 'head' ]; // check for dynamic array and merge with defaults @@ -447,11 +451,12 @@ class Assets /** * Build the CSS link tags. * + * @param string $group name of the group * @param array $attributes * * @return string */ - public function css($attributes = []) + public function css($group = 'head', $attributes = []) { if (!$this->css) { return null; @@ -479,29 +484,37 @@ class Assets $attributes = $this->attributes(array_merge(['type' => 'text/css', 'rel' => 'stylesheet'], $attributes)); $output = ''; + $inline_css = ''; + if ($this->css_pipeline) { - $pipeline_result = $this->pipelineCss(); + $pipeline_result = $this->pipelineCss($group); if ($pipeline_result) { $output .= '' . "\n"; } foreach ($this->css_no_pipeline as $file) { - $media = isset($file['media']) ? sprintf(' media="%s"', $file['media']) : ''; - $output .= '' . "\n"; + if ($group && $file['group'] == $group) { + $media = isset($file['media']) ? sprintf(' media="%s"', $file['media']) : ''; + $output .= '' . "\n"; + } } } else { foreach ($this->css as $file) { - $media = isset($file['media']) ? sprintf(' media="%s"', $file['media']) : ''; - $output .= '' . "\n"; + if ($group && $file['group'] == $group) { + $media = isset($file['media']) ? sprintf(' media="%s"', $file['media']) : ''; + $output .= '' . "\n"; + } } } // Render Inline CSS - if (count($this->inline_css) > 0) { - $output .= "\n"; + } + + if ($inline_css) { + $output .= "\n\n"; } @@ -582,7 +595,7 @@ class Assets * * @return string */ - protected function pipelineCss() + protected function pipelineCss($group = 'head') { /** @var Cache $cache */ $cache = self::getGrav()['cache']; @@ -594,7 +607,7 @@ class Assets // clear no-pipeline assets lists $this->css_no_pipeline = []; - $file = md5(json_encode($this->css) . $this->css_minify . $this->css_rewrite) . '.css'; + $file = md5(json_encode($this->css) . $this->css_minify . $this->css_rewrite . $group) . '.css'; $relative_path = "{$this->base_url}" . basename(ASSETS_DIR) . "/{$file}"; $absolute_path = ASSETS_DIR . $file; @@ -606,10 +619,12 @@ class Assets // Remove any non-pipeline files foreach ($this->css as $id => $asset) { - if (!$asset['pipeline']) { - $this->css_no_pipeline[$id] = $asset; - } else { - $temp_css[$id] = $asset; + if ($asset['group'] == $group) { + if (!$asset['pipeline']) { + $this->css_no_pipeline[$id] = $asset; + } else { + $temp_css[$id] = $asset; + } } } @@ -930,6 +945,7 @@ class Assets * Download and concatenate the content of several links. * * @param array $links + * @param bool $css * * @return string */ From a7a5625a8b4a535874de3d8e586abbf8145a8858 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sat, 24 Oct 2015 12:19:47 -0600 Subject: [PATCH 02/13] Revert "Added CSS Group asset support #374" This reverts commit f65633043a1e20fefa63eb2f394312fd05055efb. --- CHANGELOG.md | 10 ----- system/src/Grav/Common/Assets.php | 70 ++++++++++++------------------- 2 files changed, 27 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78b7c9416..8cb97d31d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,3 @@ -# v1.0.0-rc.2 -## xx/xx/2015 - -1. [](#new) - * Added support for CSS Asset groups -1. [](#improved) - * ... -1. [](#bugfix) - * ... - # v1.0.0-rc.1 ## 10/23/2015 diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index e2f39d2e5..14a9161ef 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -227,22 +227,21 @@ class Assets * It checks for duplicates. * You may add more than one asset passing an array as argument. * - * @param mixed $asset - * @param int $priority the priority, bigger comes first - * @param bool $pipeline false if this should not be pipelined - * @param null $group + * @param mixed $asset + * @param int $priority the priority, bigger comes first + * @param bool $pipeline false if this should not be pipelined * * @return $this */ - public function addCss($asset, $priority = null, $pipeline = null, $group = null) + public function addCss($asset, $priority = null, $pipeline = null) { if (is_array($asset)) { foreach ($asset as $a) { - $this->addCss($a, $priority, $pipeline, $group); + $this->addCss($a, $priority, $pipeline); } return $this; } elseif (isset($this->collections[$asset])) { - $this->add($this->collections[$asset], $priority, $pipeline, $group); + $this->add($this->collections[$asset], $priority, $pipeline); return $this; } @@ -254,8 +253,7 @@ class Assets 'asset' => $asset, 'priority' => intval($priority ?: 10), 'order' => count($this->css), - 'pipeline' => $pipeline ?: true, - 'group' => $group ?: 'head' + 'pipeline' => $pipeline ?: true ]; // check for dynamic array and merge with defaults @@ -371,12 +369,11 @@ class Assets * For adding chunks of string-based inline CSS * * @param mixed $asset - * @param int $priority the priority, bigger comes first - * @param null $group + * @param int $priority the priority, bigger comes first * * @return $this */ - public function addInlineCss($asset, $priority = null, $group = null) + public function addInlineCss($asset, $priority = null) { if (is_a($asset, 'Twig_Markup')) { $asset = strip_tags((string)$asset); @@ -385,8 +382,7 @@ class Assets $data = [ 'priority' => intval($priority ?: 10), 'order' => count($this->inline_css), - 'asset' => $asset, - 'group' => $group ?: 'head' + 'asset' => $asset ]; // check for dynamic array and merge with defaults @@ -451,12 +447,11 @@ class Assets /** * Build the CSS link tags. * - * @param string $group name of the group * @param array $attributes * * @return string */ - public function css($group = 'head', $attributes = []) + public function css($attributes = []) { if (!$this->css) { return null; @@ -484,37 +479,29 @@ class Assets $attributes = $this->attributes(array_merge(['type' => 'text/css', 'rel' => 'stylesheet'], $attributes)); $output = ''; - $inline_css = ''; - if ($this->css_pipeline) { - $pipeline_result = $this->pipelineCss($group); + $pipeline_result = $this->pipelineCss(); if ($pipeline_result) { $output .= '' . "\n"; } foreach ($this->css_no_pipeline as $file) { - if ($group && $file['group'] == $group) { - $media = isset($file['media']) ? sprintf(' media="%s"', $file['media']) : ''; - $output .= '' . "\n"; - } + $media = isset($file['media']) ? sprintf(' media="%s"', $file['media']) : ''; + $output .= '' . "\n"; } } else { foreach ($this->css as $file) { - if ($group && $file['group'] == $group) { - $media = isset($file['media']) ? sprintf(' media="%s"', $file['media']) : ''; - $output .= '' . "\n"; - } + $media = isset($file['media']) ? sprintf(' media="%s"', $file['media']) : ''; + $output .= '' . "\n"; } } // Render Inline CSS - foreach ($this->inline_css as $inline) { - if ($group && $inline['group'] == $group) { - $inline_css .= $inline['asset'] . "\n"; + if (count($this->inline_css) > 0) { + $output .= "\n"; + $output .= "\n"; } @@ -595,7 +582,7 @@ class Assets * * @return string */ - protected function pipelineCss($group = 'head') + protected function pipelineCss() { /** @var Cache $cache */ $cache = self::getGrav()['cache']; @@ -607,7 +594,7 @@ class Assets // clear no-pipeline assets lists $this->css_no_pipeline = []; - $file = md5(json_encode($this->css) . $this->css_minify . $this->css_rewrite . $group) . '.css'; + $file = md5(json_encode($this->css) . $this->css_minify . $this->css_rewrite) . '.css'; $relative_path = "{$this->base_url}" . basename(ASSETS_DIR) . "/{$file}"; $absolute_path = ASSETS_DIR . $file; @@ -619,12 +606,10 @@ class Assets // Remove any non-pipeline files foreach ($this->css as $id => $asset) { - if ($asset['group'] == $group) { - if (!$asset['pipeline']) { - $this->css_no_pipeline[$id] = $asset; - } else { - $temp_css[$id] = $asset; - } + if (!$asset['pipeline']) { + $this->css_no_pipeline[$id] = $asset; + } else { + $temp_css[$id] = $asset; } } @@ -945,7 +930,6 @@ class Assets * Download and concatenate the content of several links. * * @param array $links - * @param bool $css * * @return string */ From fcdd0bc0e9d35118090edbab933b2bd967f95076 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Fri, 11 Dec 2015 18:44:52 -0800 Subject: [PATCH 03/13] Reverted CleanCommand to pure Command --- system/src/Grav/Console/Cli/CleanCommand.php | 41 ++++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/system/src/Grav/Console/Cli/CleanCommand.php b/system/src/Grav/Console/Cli/CleanCommand.php index a5237e521..767406bfc 100644 --- a/system/src/Grav/Console/Cli/CleanCommand.php +++ b/system/src/Grav/Console/Cli/CleanCommand.php @@ -2,14 +2,24 @@ namespace Grav\Console\Cli; use Grav\Common\Filesystem\Folder; -use Grav\Console\ConsoleCommand; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Formatter\OutputFormatterStyle; /** * Class CleanCommand * @package Grav\Console\Cli */ -class CleanCommand extends ConsoleCommand +class CleanCommand extends Command { + /* @var InputInterface $output */ + protected $input; + + /* @var OutputInterface $output */ + protected $output; + /** * @var array */ @@ -174,8 +184,10 @@ class CleanCommand extends ConsoleCommand /** * @return int|null|void */ - protected function serve() + protected function execute(InputInterface $input, OutputInterface $output) { + $this->setupConsole($input, $output); + $this->cleanPaths(); } @@ -183,12 +195,9 @@ class CleanCommand extends ConsoleCommand { $this->output->writeln(''); $this->output->writeln('DELETING'); - $anything = false; - foreach ($this->paths_to_remove as $path) { $path = ROOT_DIR . $path; - if (is_dir($path) && @Folder::delete($path)) { $anything = true; $this->output->writeln('dir: ' . $path); @@ -197,12 +206,30 @@ class CleanCommand extends ConsoleCommand $this->output->writeln('file: ' . $path); } } - if (!$anything) { $this->output->writeln(''); $this->output->writeln('Nothing to clean...'); } + } + /** + * Set colors style definition for the formatter. + * + * @param InputInterface $input + * @param OutputInterface $output + */ + public function setupConsole(InputInterface $input, OutputInterface $output) + { + $this->input = $input; + $this->output = $output; + + $this->output->getFormatter()->setStyle('normal', new OutputFormatterStyle('white')); + $this->output->getFormatter()->setStyle('yellow', new OutputFormatterStyle('yellow', null, array('bold'))); + $this->output->getFormatter()->setStyle('red', new OutputFormatterStyle('red', null, array('bold'))); + $this->output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan', null, array('bold'))); + $this->output->getFormatter()->setStyle('green', new OutputFormatterStyle('green', null, array('bold'))); + $this->output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta', null, array('bold'))); + $this->output->getFormatter()->setStyle('white', new OutputFormatterStyle('white', null, array('bold'))); } } From c36b26878f7d21e86effa350457b5c97cdf3aaaa Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 10 Feb 2017 11:51:30 -0700 Subject: [PATCH 04/13] Updated changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7ff12bd6..9a3f1de9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,12 @@ 1. [](#new) * Exposed the Pages cache ID for use by plugins (e.g. Form) via `Pages::getPagesCacheId()` + * Added `Languages::resetFallbackPageExtensions()` regarding [#1276](https://github.com/getgrav/grav/pull/1276) 1. [](#improved) * Allowed CLI to use non-volatile cache drivers for better integration with CLI and Web caches + * Added Gantry5-compatible query information to Caddy configuration + * Added some missing docblocks and type-hints + * Various code cleanups (return types, missing variables in doclbocks, etc.) 1. [](#bugfix) * Fix blueprints slug validation [https://github.com/getgrav/grav-plugin-admin/issues/955](https://github.com/getgrav/grav-plugin-admin/issues/955) From 5b031251506ca2bf3dc198e51c2d1eb6f2c77596 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 10 Feb 2017 11:52:21 -0700 Subject: [PATCH 05/13] Prepare for release --- CHANGELOG.md | 2 +- system/defines.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a3f1de9b..af53b6c95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v1.1.16 -## xx/xx/2017 +## 02/10/2017 1. [](#new) * Exposed the Pages cache ID for use by plugins (e.g. Form) via `Pages::getPagesCacheId()` diff --git a/system/defines.php b/system/defines.php index 44cd1c54e..d033a98d8 100644 --- a/system/defines.php +++ b/system/defines.php @@ -8,7 +8,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.1.15'); +define('GRAV_VERSION', '1.1.16'); define('GRAV_TESTING', false); define('DS', '/'); define('GRAV_PHP_MIN', '5.5.9'); From 7ab0aee44aa382e2d98ba5c85b9250009e16e503 Mon Sep 17 00:00:00 2001 From: Pia Mancini Date: Wed, 15 Feb 2017 15:14:51 -0800 Subject: [PATCH 06/13] add space for sponsor's logo's to show inline (#1308) --- README.md | 1 + 1 file changed, 1 insertion(+) 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)] + From 33a63de4f10b62b7d385ff9f9ad0d3953846fd94 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 15 Feb 2017 17:21:16 -0700 Subject: [PATCH 07/13] Fix for double extension during some redirects #1307 --- system/src/Grav/Common/Page/Pages.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; } From 724f24335a9ea44f614b9ae2a76766836985d8ce Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 15 Feb 2017 17:22:53 -0700 Subject: [PATCH 08/13] Updated changelog --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af53b6c95..93aa4783c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.1.17 +## xx/xx/2017 + +1. [](#bugfix) + * Fix for double extensions getting added during some redirects [#1307](https://github.com/getgrav/grav/issues/1307) + # v1.1.16 ## 02/10/2017 @@ -11,7 +17,7 @@ * Various code cleanups (return types, missing variables in doclbocks, etc.) 1. [](#bugfix) * Fix blueprints slug validation [https://github.com/getgrav/grav-plugin-admin/issues/955](https://github.com/getgrav/grav-plugin-admin/issues/955) - + # v1.1.15 ## 01/30/2017 From e2cc55a4e3294d5855d27c7a1ca3daa5d9a99185 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Thu, 16 Feb 2017 10:16:30 +0100 Subject: [PATCH 09/13] Fix syntax error in PHP 5.3. Move the version check before requiring the autoloaded deps --- CHANGELOG.md | 3 ++- index.php | 9 +++++---- system/defines.php | 1 - 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93aa4783c..334174275 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 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 # v1.1.16 ## 02/10/2017 @@ -17,7 +18,7 @@ * Various code cleanups (return types, missing variables in doclbocks, etc.) 1. [](#bugfix) * Fix blueprints slug validation [https://github.com/getgrav/grav-plugin-admin/issues/955](https://github.com/getgrav/grav-plugin-admin/issues/955) - + # v1.1.15 ## 01/30/2017 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..9f2975723 100644 --- a/system/defines.php +++ b/system/defines.php @@ -11,7 +11,6 @@ define('GRAV', true); define('GRAV_VERSION', '1.1.16'); define('GRAV_TESTING', false); define('DS', '/'); -define('GRAV_PHP_MIN', '5.5.9'); // Directories and Paths if (!defined('GRAV_ROOT')) { From a3ccae5915fa1db501b231dbf74a470bea93e4c0 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Thu, 16 Feb 2017 10:37:35 +0100 Subject: [PATCH 10/13] Fix GRAV_PHP_MIN for CLI --- system/defines.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/defines.php b/system/defines.php index 9f2975723..14993a8ae 100644 --- a/system/defines.php +++ b/system/defines.php @@ -12,6 +12,10 @@ define('GRAV_VERSION', '1.1.16'); define('GRAV_TESTING', false); define('DS', '/'); +if (!defined('GRAV_PHP_MIN')) { + define('GRAV_PHP_MIN', '5.5.9'); +} + // Directories and Paths if (!defined('GRAV_ROOT')) { define('GRAV_ROOT', str_replace(DIRECTORY_SEPARATOR, DS, getcwd())); From 14bde9f31f5cb2275f15bce406cb407cae05f374 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 17 Feb 2017 10:35:33 +0200 Subject: [PATCH 11/13] Fix Whoops displaying error page if there is PHP core warning or error (#980) --- CHANGELOG.md | 1 + system/src/Grav/Common/Errors/Errors.php | 3 +- .../src/Grav/Common/Errors/SystemFacade.php | 39 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 system/src/Grav/Common/Errors/SystemFacade.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 334174275..534bc5065 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ 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 (#980) # v1.1.16 ## 02/10/2017 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(); + } + } +} From b9424922a20869e1fd05d05f4211bfba286693d5 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 17 Feb 2017 10:38:05 +0200 Subject: [PATCH 12/13] Changelog update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 534bc5065..73041332c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ 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 (#980) + * 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 From 50b355aaea57bf30f0bedde22c85148fbfb0f0e3 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 17 Feb 2017 14:57:48 -0700 Subject: [PATCH 13/13] Prepare for release --- CHANGELOG.md | 2 +- system/defines.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73041332c..c2996b161 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v1.1.17 -## xx/xx/2017 +## 02/17/2017 1. [](#bugfix) * Fix for double extensions getting added during some redirects [#1307](https://github.com/getgrav/grav/issues/1307) diff --git a/system/defines.php b/system/defines.php index 14993a8ae..387435b35 100644 --- a/system/defines.php +++ b/system/defines.php @@ -8,7 +8,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.1.16'); +define('GRAV_VERSION', '1.1.17'); define('GRAV_TESTING', false); define('DS', '/');