From a7a9b5d1324cbb7451de0eed0c1c589025da5d98 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 13 May 2022 17:04:32 +0300 Subject: [PATCH 1/4] Fixed a potential fatal error when using watermark in images --- CHANGELOG.md | 6 ++++++ system/src/Grav/Common/Page/Medium/ImageMedium.php | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04b07a81e..7d5f7d76b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.7.34 +## mm/dd/2022 + +1. [](#bugfix) + * Fixed a potential fatal error when using watermark in images + # v1.7.33 ## 04/25/2022 diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php index 42d8f0e75..ab6ba4a90 100644 --- a/system/src/Grav/Common/Page/Medium/ImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php @@ -361,8 +361,8 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate // Scaling operations $scale = ($scale ?? $config->get('system.images.watermark.scale', 100)) / 100; - $wwidth = $this->get('width') * $scale; - $wheight = $this->get('height') * $scale; + $wwidth = (int)$this->get('width') * $scale; + $wheight = (int)$this->get('height') * $scale; $watermark->resize($wwidth, $wheight); // Position operations @@ -377,11 +377,11 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate break; case 'bottom': - $positionY = $this->get('height')-$wheight; + $positionY = (int)$this->get('height')-$wheight; break; case 'center': - $positionY = ($this->get('height')/2) - ($wheight/2); + $positionY = ((int)$this->get('height')/2) - ($wheight/2); break; } @@ -392,11 +392,11 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate break; case 'right': - $positionX = $this->get('width')-$wwidth; + $positionX = (int)$this->get('width')-$wwidth; break; case 'center': - $positionX = ($this->get('width')/2) - ($wwidth/2); + $positionX = ((int)$this->get('width')/2) - ($wwidth/2); break; } From 6fa96ca5545346cea152f2a748ada8950acba837 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 20 May 2022 15:55:38 +0300 Subject: [PATCH 2/4] Regression: Fixed saving page with a new language causing cache corruption [#2282] --- CHANGELOG.md | 1 + composer.lock | 12 ++++++------ system/src/Grav/Common/File/CompiledFile.php | 4 ++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d5f7d76b..cbceb3641 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## mm/dd/2022 1. [](#bugfix) + * Regression: Fixed saving page with a new language causing cache corruption [#2282](https://github.com/getgrav/grav-plugin-admin/issues/2282) * Fixed a potential fatal error when using watermark in images # v1.7.33 diff --git a/composer.lock b/composer.lock index 88afa4202..fc34f8221 100644 --- a/composer.lock +++ b/composer.lock @@ -4679,16 +4679,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.6.7", + "version": "1.6.8", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "d41c39cb2e487663bce9bbd97c660e244b73abad" + "reference": "d76498c5531232cb8386ceb6004f7e013138d3ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d41c39cb2e487663bce9bbd97c660e244b73abad", - "reference": "d41c39cb2e487663bce9bbd97c660e244b73abad", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d76498c5531232cb8386ceb6004f7e013138d3ba", + "reference": "d76498c5531232cb8386ceb6004f7e013138d3ba", "shasum": "" }, "require": { @@ -4714,7 +4714,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.6.7" + "source": "https://github.com/phpstan/phpstan/tree/1.6.8" }, "funding": [ { @@ -4734,7 +4734,7 @@ "type": "tidelift" } ], - "time": "2022-05-04T22:55:41+00:00" + "time": "2022-05-10T06:54:21+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", diff --git a/system/src/Grav/Common/File/CompiledFile.php b/system/src/Grav/Common/File/CompiledFile.php index 9393ab70f..eaf46f702 100644 --- a/system/src/Grav/Common/File/CompiledFile.php +++ b/system/src/Grav/Common/File/CompiledFile.php @@ -138,6 +138,10 @@ trait CompiledFile $class = get_class($this); $size = filesize($filename); + // Reload data from the filesystem. This ensures that we always cache the correct data (see issue #2282). + $this->raw = $this->content = null; + $data = (array)$this->decode($this->raw()); + // Decode data into compiled array. $cache = [ '@class' => $class, From 3bf979bd0f8eb2127dcb4a605c87b9a879694b22 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 20 May 2022 15:57:03 +0300 Subject: [PATCH 3/4] Changelog update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbceb3641..d86c43f08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## mm/dd/2022 1. [](#bugfix) - * Regression: Fixed saving page with a new language causing cache corruption [#2282](https://github.com/getgrav/grav-plugin-admin/issues/2282) + * Regression: Fixed saving page with a new language causing cache corruption [getgrav/grav-plugin-admin##2282](https://github.com/getgrav/grav-plugin-admin/issues/2282) * Fixed a potential fatal error when using watermark in images # v1.7.33 From e6320fa32770db6e4508fe067889324bd6c5620f Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 20 May 2022 16:40:54 +0300 Subject: [PATCH 4/4] Changelog update (typo) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d86c43f08..bead369f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## mm/dd/2022 1. [](#bugfix) - * Regression: Fixed saving page with a new language causing cache corruption [getgrav/grav-plugin-admin##2282](https://github.com/getgrav/grav-plugin-admin/issues/2282) + * Regression: Fixed saving page with a new language causing cache corruption [getgrav/grav-plugin-admin#2282](https://github.com/getgrav/grav-plugin-admin/issues/2282) * Fixed a potential fatal error when using watermark in images # v1.7.33