Skip to content

Commit aea4197

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.5
Conflicts: phpstan-baseline.php user_guide_src/source/changelogs/index.rst user_guide_src/source/installation/upgrading.rst
2 parents 0bab68b + 67fa536 commit aea4197

File tree

11 files changed

+168
-87
lines changed

11 files changed

+168
-87
lines changed

admin/RELEASE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Work off direct clones of the repos so the release branches persist for a time.
8888
> generating much new content.
8989
9090
* [ ] Replace **CHANGELOG.md** with the new version generated above
91-
* [ ] Update **user_guide_src/source/changelogs/{version}.rst**
91+
* [ ] Update **user_guide_src/source/changelogs/v4.x.x.rst**
9292
* Remove the section titles that have no items
9393
* [ ] Update **user_guide_src/source/installation/upgrade_{ver}.rst**
9494
* fill in the "All Changes" section, and add it to **upgrading.rst**
@@ -150,10 +150,10 @@ Work off direct clones of the repos so the release branches persist for a time.
150150
composer test && composer info codeigniter4/framework
151151
```
152152
* [ ] Verify that the user guide actions succeeded:
153-
* "[Deploy Distributable Repos](https://github.com/codeigniter4/CodeIgniter4/actions/workflows/deploy-distributables.yml)", the main repo
154-
* "[Deploy Production](https://github.com/codeigniter4/userguide/actions/workflows/deploy.yml)", UG repo
155-
* "[pages-build-deployment](https://github.com/codeigniter4/userguide/actions/workflows/pages/pages-build-deployment)", UG repo
156-
* Check if "CodeIgniter4.x.x.epub" is added to UG repo. "CodeIgniter.epub" was
153+
* [ ] "[Deploy Distributable Repos](https://github.com/codeigniter4/CodeIgniter4/actions/workflows/deploy-distributables.yml)", the main repo
154+
* [ ] "[Deploy Production](https://github.com/codeigniter4/userguide/actions/workflows/deploy.yml)", UG repo
155+
* [ ] "[pages-build-deployment](https://github.com/codeigniter4/userguide/actions/workflows/pages/pages-build-deployment)", UG repo
156+
* [ ] Check if "CodeIgniter4.x.x.epub" is added to UG repo. "CodeIgniter.epub" was
157157
created when v4.3.8 was released.
158158
* [ ] Fast-forward `develop` branch to catch the merge commit from `master`
159159
```console

admin/prepare-release.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function replace_file_content(string $path, string $pattern, string $replace): v
2626

2727
// Creates a branch for release.
2828
system('git switch develop');
29+
system('git branch -D release-' . $version);
2930
system('git switch -c release-' . $version);
3031

3132
// Updates version number in "CodeIgniter.php".

phpstan-baseline.php

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,6 @@
221221
'count' => 1,
222222
'path' => __DIR__ . '/system/BaseModel.php',
223223
];
224-
$ignoreErrors[] = [
225-
'message' => '#^Method CodeIgniter\\\\BaseModel\\:\\:setValidationRules\\(\\) has parameter \\$validationRules with no value type specified in iterable type array\\.$#',
226-
'count' => 1,
227-
'path' => __DIR__ . '/system/BaseModel.php',
228-
];
229224
$ignoreErrors[] = [
230225
'message' => '#^Method CodeIgniter\\\\BaseModel\\:\\:transformDataToArray\\(\\) return type has no value type specified in iterable type array\\.$#',
231226
'count' => 1,
@@ -7368,7 +7363,7 @@
73687363
];
73697364
$ignoreErrors[] = [
73707365
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
7371-
'count' => 9,
7366+
'count' => 8,
73727367
'path' => __DIR__ . '/system/Images/Handlers/ImageMagickHandler.php',
73737368
];
73747369
$ignoreErrors[] = [
@@ -10821,16 +10816,6 @@
1082110816
'count' => 1,
1082210817
'path' => __DIR__ . '/tests/_support/Models/UserModel.php',
1082310818
];
10824-
$ignoreErrors[] = [
10825-
'message' => '#^Property Tests\\\\Support\\\\Models\\\\ValidErrorsModel\\:\\:\\$validationRules \\(array\\<int, string\\>\\|string\\) does not accept default value of type array\\<string, array\\<int\\|string, array\\<string, string\\>\\|string\\>\\|string\\>\\.$#',
10826-
'count' => 1,
10827-
'path' => __DIR__ . '/tests/_support/Models/ValidErrorsModel.php',
10828-
];
10829-
$ignoreErrors[] = [
10830-
'message' => '#^Property Tests\\\\Support\\\\Models\\\\ValidModel\\:\\:\\$validationRules \\(array\\<int, string\\>\\|string\\) does not accept default value of type array\\<string, array\\<int, string\\>\\|string\\>\\.$#',
10831-
'count' => 1,
10832-
'path' => __DIR__ . '/tests/_support/Models/ValidModel.php',
10833-
];
1083410819
$ignoreErrors[] = [
1083510820
'message' => '#^Method Tests\\\\Support\\\\Services\\\\Translation\\\\Nested\\\\TranslationFour\\:\\:list\\(\\) has no return type specified\\.$#',
1083610821
'count' => 1,
@@ -16031,41 +16016,11 @@
1603116016
'count' => 1,
1603216017
'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php',
1603316018
];
16034-
$ignoreErrors[] = [
16035-
'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelRuleGroupTest\\.php\\:370\\:\\:\\$validationRules \\(array\\<int, string\\>\\|string\\) does not accept default value of type array\\<string, string\\>\\.$#',
16036-
'count' => 1,
16037-
'path' => __DIR__ . '/tests/system/Models/ValidationModelRuleGroupTest.php',
16038-
];
16039-
$ignoreErrors[] = [
16040-
'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelRuleGroupTest\\.php\\:408\\:\\:\\$validationRules \\(array\\<int, string\\>\\|string\\) does not accept default value of type array\\<string, string\\>\\.$#',
16041-
'count' => 1,
16042-
'path' => __DIR__ . '/tests/system/Models/ValidationModelRuleGroupTest.php',
16043-
];
16044-
$ignoreErrors[] = [
16045-
'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelRuleGroupTest\\.php\\:448\\:\\:\\$validationRules \\(array\\<int, string\\>\\|string\\) does not accept default value of type array\\<string, string\\>\\.$#',
16046-
'count' => 1,
16047-
'path' => __DIR__ . '/tests/system/Models/ValidationModelRuleGroupTest.php',
16048-
];
1604916019
$ignoreErrors[] = [
1605016020
'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelTest\\.php\\:245\\:\\:\\$grouptest has no type specified\\.$#',
1605116021
'count' => 1,
1605216022
'path' => __DIR__ . '/tests/system/Models/ValidationModelTest.php',
1605316023
];
16054-
$ignoreErrors[] = [
16055-
'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelTest\\.php\\:382\\:\\:\\$validationRules \\(array\\<int, string\\>\\|string\\) does not accept default value of type array\\<string, string\\>\\.$#',
16056-
'count' => 1,
16057-
'path' => __DIR__ . '/tests/system/Models/ValidationModelTest.php',
16058-
];
16059-
$ignoreErrors[] = [
16060-
'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelTest\\.php\\:420\\:\\:\\$validationRules \\(array\\<int, string\\>\\|string\\) does not accept default value of type array\\<string, string\\>\\.$#',
16061-
'count' => 1,
16062-
'path' => __DIR__ . '/tests/system/Models/ValidationModelTest.php',
16063-
];
16064-
$ignoreErrors[] = [
16065-
'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelTest\\.php\\:460\\:\\:\\$validationRules \\(array\\<int, string\\>\\|string\\) does not accept default value of type array\\<string, string\\>\\.$#',
16066-
'count' => 1,
16067-
'path' => __DIR__ . '/tests/system/Models/ValidationModelTest.php',
16068-
];
1606916024
$ignoreErrors[] = [
1607016025
'message' => '#^Cannot access property \\$key on array\\.$#',
1607116026
'count' => 7,

system/BaseModel.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,14 @@ abstract class BaseModel
205205
protected bool $updateOnlyChanged = true;
206206

207207
/**
208-
* Rules used to validate data in insert, update, and save methods.
208+
* Rules used to validate data in insert(), update(), and save() methods.
209+
*
209210
* The array must match the format of data passed to the Validation
210211
* library.
211212
*
212-
* @var list<string>|string
213+
* @see https://codeigniter4.github.io/userguide/models/model.html#setting-validation-rules
214+
*
215+
* @var array<string, array<string, array<string, string>|string>|string>|string
213216
*/
214217
protected $validationRules = [];
215218

@@ -1487,7 +1490,7 @@ public function setValidationMessage(string $field, array $fieldMessages)
14871490
* Allows to set (and reset) validation rules.
14881491
* It could be used when you have to change default or override current validate rules.
14891492
*
1490-
* @param array $validationRules Value
1493+
* @param array<string, array<string, array<string, string>|string>|string> $validationRules Value
14911494
*
14921495
* @return $this
14931496
*/

system/Images/Handlers/ImageMagickHandler.php

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ class ImageMagickHandler extends BaseHandler
3434
protected $resource;
3535

3636
/**
37-
* Constructor.
38-
*
3937
* @param Images $config
4038
*
4139
* @throws ImageException
@@ -47,6 +45,22 @@ public function __construct($config = null)
4745
if (! (extension_loaded('imagick') || class_exists(Imagick::class))) {
4846
throw ImageException::forMissingExtension('IMAGICK'); // @codeCoverageIgnore
4947
}
48+
49+
$cmd = $this->config->libraryPath;
50+
51+
if ($cmd === '') {
52+
throw ImageException::forInvalidImageLibraryPath($cmd);
53+
}
54+
55+
if (preg_match('/convert$/i', $cmd) !== 1) {
56+
$cmd = rtrim($cmd, '\/') . '/convert';
57+
58+
$this->config->libraryPath = $cmd;
59+
}
60+
61+
if (! is_file($cmd)) {
62+
throw ImageException::forInvalidImageLibraryPath($cmd);
63+
}
5064
}
5165

5266
/**
@@ -169,12 +183,10 @@ protected function _flip(string $direction)
169183
*/
170184
public function getVersion(): string
171185
{
172-
$result = $this->process('-version');
186+
$versionString = $this->process('-version')[0];
187+
preg_match('/ImageMagick\s(?P<version>[\S]+)/', $versionString, $matches);
173188

174-
// The first line has the version in it...
175-
preg_match('/(ImageMagick\s[\S]+)/', $result[0], $matches);
176-
177-
return str_replace('ImageMagick ', '', $matches[0]);
189+
return $matches['version'];
178190
}
179191

180192
/**
@@ -186,19 +198,10 @@ public function getVersion(): string
186198
*/
187199
protected function process(string $action, int $quality = 100): array
188200
{
189-
// Do we have a vaild library path?
190-
if (empty($this->config->libraryPath)) {
191-
throw ImageException::forInvalidImageLibraryPath($this->config->libraryPath);
192-
}
193-
194201
if ($action !== '-version') {
195202
$this->supportedFormatCheck();
196203
}
197204

198-
if (! preg_match('/convert$/i', $this->config->libraryPath)) {
199-
$this->config->libraryPath = rtrim($this->config->libraryPath, '/') . '/convert';
200-
}
201-
202205
$cmd = $this->config->libraryPath;
203206
$cmd .= $action === '-version' ? ' ' . $action : ' -quality ' . $quality . ' ' . $action;
204207

tests/system/Images/ImageMagickHandlerTest.php

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use CodeIgniter\Config\Services;
1717
use CodeIgniter\Images\Exceptions\ImageException;
1818
use CodeIgniter\Images\Handlers\BaseHandler;
19+
use CodeIgniter\Images\Handlers\ImageMagickHandler;
1920
use CodeIgniter\Test\CIUnitTestCase;
2021
use Config\Images;
2122
use Imagick;
@@ -79,14 +80,40 @@ protected function setUp(): void
7980
$this->handler = Services::image('imagick', $config, false);
8081
}
8182

83+
/**
84+
* @dataProvider provideNonexistentLibraryPathTerminatesProcessing
85+
*/
86+
public function testNonexistentLibraryPathTerminatesProcessing(string $path, string $invalidPath): void
87+
{
88+
$this->expectException(ImageException::class);
89+
$this->expectExceptionMessage(lang('Images.libPathInvalid', [$invalidPath]));
90+
91+
$config = new Images();
92+
93+
$config->libraryPath = $path;
94+
95+
new ImageMagickHandler($config);
96+
}
97+
98+
/**
99+
* @return iterable<string, list<string>>
100+
*/
101+
public static function provideNonexistentLibraryPathTerminatesProcessing(): iterable
102+
{
103+
yield 'empty string' => ['', ''];
104+
105+
yield 'invalid file' => ['/var/log/convert', '/var/log/convert'];
106+
107+
yield 'nonexistent file' => ['/var/www/file', '/var/www/file/convert'];
108+
}
109+
82110
public function testGetVersion(): void
83111
{
84112
$version = $this->handler->getVersion();
85-
// make sure that the call worked
86-
$this->assertNotFalse($version);
87-
// we should have a numeric version, greater than 6
88-
$this->assertGreaterThanOrEqual(0, version_compare($version, '6.0.0'));
89-
$this->assertLessThan(0, version_compare($version, '99.0.0'));
113+
114+
$this->assertNotSame('', $version);
115+
$this->assertTrue(version_compare($version, '6.0.0', '>'));
116+
$this->assertTrue(version_compare($version, '99.0.0', '<'));
90117
}
91118

92119
public function testImageProperties(): void

user_guide_src/source/changelogs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ See all the changes.
1313
:titlesonly:
1414

1515
v4.5.0
16+
v4.4.8
1617
v4.4.7
1718
v4.4.6
1819
v4.4.5
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#############
2+
Version 4.4.8
3+
#############
4+
5+
Release Date: Unreleased
6+
7+
**4.4.8 release of CodeIgniter4**
8+
9+
.. contents::
10+
:local:
11+
:depth: 3
12+
13+
********
14+
BREAKING
15+
********
16+
17+
***************
18+
Message Changes
19+
***************
20+
21+
*******
22+
Changes
23+
*******
24+
25+
************
26+
Deprecations
27+
************
28+
29+
**********
30+
Bugs Fixed
31+
**********
32+
33+
See the repo's
34+
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_
35+
for a complete list of bugs fixed.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#############################
2+
Upgrading from 4.4.7 to 4.4.8
3+
#############################
4+
5+
Please refer to the upgrade instructions corresponding to your installation method.
6+
7+
- :ref:`Composer Installation App Starter Upgrading <app-starter-upgrading>`
8+
- :ref:`Composer Installation Adding CodeIgniter4 to an Existing Project Upgrading <adding-codeigniter4-upgrading>`
9+
- :ref:`Manual Installation Upgrading <installing-manual-upgrading>`
10+
11+
.. contents::
12+
:local:
13+
:depth: 2
14+
15+
**********************
16+
Mandatory File Changes
17+
**********************
18+
19+
****************
20+
Breaking Changes
21+
****************
22+
23+
*********************
24+
Breaking Enhancements
25+
*********************
26+
27+
*************
28+
Project Files
29+
*************
30+
31+
Some files in the **project space** (root, app, public, writable) received updates. Due to
32+
these files being outside of the **system** scope they will not be changed without your intervention.
33+
34+
There are some third-party CodeIgniter modules available to assist with merging changes to
35+
the project space: `Explore on Packagist <https://packagist.org/explore/?query=codeigniter4%20updates>`_.
36+
37+
Content Changes
38+
===============
39+
40+
The following files received significant changes (including deprecations or visual adjustments)
41+
and it is recommended that you merge the updated versions with your application:
42+
43+
Config
44+
------
45+
46+
- @TODO
47+
48+
All Changes
49+
===========
50+
51+
This is a list of all files in the **project space** that received changes;
52+
many will be simple comments or formatting that have no effect on the runtime:
53+
54+
- @TODO

user_guide_src/source/installation/upgrading.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ See also :doc:`./backward_compatibility_notes`.
1717
backward_compatibility_notes
1818

1919
upgrade_450
20+
upgrade_448
2021
upgrade_447
2122
upgrade_446
2223
upgrade_445

0 commit comments

Comments
 (0)