Skip to content

Commit d94e054

Browse files
committed
Merge branch 'develop' into 4.3
2 parents b6840cd + 26b247d commit d94e054

File tree

27 files changed

+194
-79
lines changed

27 files changed

+194
-79
lines changed

CHANGELOG.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,59 @@
11
# Changelog
22

3+
## [v4.2.2](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.2) (2022-08-05)
4+
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.1...v4.2.2)
5+
6+
### Breaking Changes
7+
* fix: when running on CLI, two Request objects were used in the system by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6089
8+
* fix: Builder insert()/update() does not accept an object by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6216
9+
* fix: create table if not exists when indexes already exist by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6249
10+
* fix: page cache saves Response data before running after filters by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6282
11+
* fix: random_string('crypto') may return string less than $len or ErrorException by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6334
12+
13+
### Fixed Bugs
14+
* Fixed: BaseBuilder increment/decrement do not reset state after a query by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6146
15+
* fix: SQLite3\Connection\getIndexData() error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6152
16+
* fix: `is_image` causes PHP 8.1 deprecated error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6157
17+
* fix: prepared query is executed when using QueryBuilder by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6164
18+
* fix: Time::getAge() calculation by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6159
19+
* fix: Session cookies are sent twice with Ajax by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6167
20+
* fix: QueryBuilder breaks select when escape is false by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5118
21+
* fix: PHPDoc return type in ControllerTestTrait methods by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6168
22+
* fix: `$routes->group('/', ...)` creates the route `foo///bar` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6186
23+
* fix: use lang('HTTP.pageNotFound') on production 404 page by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6202
24+
* fix: BaseConnection may create dynamic property by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6198
25+
* fix: Email SMTP may throw Uncaught ErrorException by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6184
26+
* fix: CSP reportOnly behavior by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6201
27+
* fix: lang() causes Error on CLI by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6209
28+
* fix: multiple pagers with models do not work by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6211
29+
* fix: tweak empty line output of `spark db:table` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6215
30+
* fix: custom validation error is cleared when calling setRule() twice by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6241
31+
* Fix: Validation of fields with a leading asterisk. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6243
32+
* fix: Call to undefined method CodeIgniter\Pager\PagerRenderer::getDetails() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6251
33+
* fix: exceptionHandler may cause HTTPException: Unknown HTTP status code by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6254
34+
* fix: invalid INSERT/DELETE query when Query Builder uses table alias by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5376
35+
* fix: Add db port entry into env file. by @nalakapws in https://github.com/codeigniter4/CodeIgniter4/pull/6250
36+
* fix: update `.gitattributes` by @totoprayogo1916 in https://github.com/codeigniter4/CodeIgniter4/pull/6256
37+
* fix: format_number() can't be used on CLI by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6263
38+
* fix: add parameter checking for max_size by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6261
39+
* fix: route name is not displayed in Exception message by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6269
40+
* fix: `spark routes` shows 404 error when using regex by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6279
41+
* fix: Entity::hasChanged() returns wrong result to mapped property by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6285
42+
* fix: unable to add more than one file to FileCollection constructor by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6291
43+
* fix: Security::derandomize() may cause hex2bin() error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6292
44+
* fix: use getenv() instead of $_SERVER in detectEnvironment() by @fcosrno in https://github.com/codeigniter4/CodeIgniter4/pull/6257
45+
* fix: OCI8 uses deprecated Entity by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6323
46+
* fix: Parse error occurs before PHP version check by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6327
47+
* fix: 404 page might display Exception message in production environment by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6333
48+
49+
### Refactoring
50+
* refactor: replace $e->getMessage() with $e in log_message() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6182
51+
* refactor: add CompleteDynamicPropertiesRector by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6187
52+
* refactor: debug toolbar by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6272
53+
* refactor: Exception exit code by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6286
54+
* chore: Remove Vagrant by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6314
55+
* refactor: CSRF protection by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6320
56+
357
## [v4.2.1](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.1) (2022-06-16)
458
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.0...v4.2.1)
559

app/Views/errors/html/error_404.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<h1>404</h1>
7474

7575
<p>
76-
<?php if (! empty($message) && $message !== '(null)') : ?>
76+
<?php if (ENVIRONMENT !== 'production') : ?>
7777
<?= nl2br(esc($message)) ?>
7878
<?php else : ?>
7979
<?= lang('Errors.sorryCannotFind') ?>

composer.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,21 @@
2424
"phpstan/phpstan": "^1.7.1",
2525
"phpunit/phpunit": "^9.1",
2626
"predis/predis": "^1.1 || ^2.0",
27-
"rector/rector": "0.13.9"
27+
"rector/rector": "0.13.10"
2828
},
2929
"suggest": {
30-
"ext-fileinfo": "Improves mime type detection for files"
30+
"ext-imagick": "If you use Image class ImageMagickHandler",
31+
"ext-simplexml": "If you format XML",
32+
"ext-mysqli": "If you use MySQL",
33+
"ext-oci8": "If you use Oracle Database",
34+
"ext-pgsql": "If you use PostgreSQL",
35+
"ext-sqlsrv": "If you use SQL Server",
36+
"ext-sqlite3": "If you use SQLite3",
37+
"ext-memcache": "If you use Cache class MemcachedHandler with Memcache",
38+
"ext-memcached": "If you use Cache class MemcachedHandler with Memcached",
39+
"ext-redis": "If you use Cache class RedisHandler",
40+
"ext-fileinfo": "Improves mime type detection for files",
41+
"ext-readline": "Improves CLI::input() usability"
3142
},
3243
"config": {
3344
"optimize-autoloader": true,

phpstan-baseline.neon.dist

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ parameters:
5050
count: 1
5151
path: system/Cache/Handlers/MemcachedHandler.php
5252

53-
-
54-
message: "#^Variable \\$config in empty\\(\\) always exists and is not falsy\\.$#"
55-
count: 1
56-
path: system/Cache/Handlers/MemcachedHandler.php
57-
5853
-
5954
message: "#^Variable \\$data might not be defined\\.$#"
6055
count: 1
@@ -65,11 +60,6 @@ parameters:
6560
count: 1
6661
path: system/Cache/Handlers/RedisHandler.php
6762

68-
-
69-
message: "#^Variable \\$config in empty\\(\\) always exists and is not falsy\\.$#"
70-
count: 1
71-
path: system/Cache/Handlers/RedisHandler.php
72-
7363
-
7464
message: "#^Call to an undefined method CodeIgniter\\\\HTTP\\\\Request\\:\\:getPost\\(\\)\\.$#"
7565
count: 1
@@ -395,11 +385,6 @@ parameters:
395385
count: 2
396386
path: system/Database/SQLite3/Result.php
397387

398-
-
399-
message: "#^Expression on left side of \\?\\? is not nullable\\.$#"
400-
count: 1
401-
path: system/Debug/Exceptions.php
402-
403388
-
404389
message: "#^Call to an undefined method CodeIgniter\\\\View\\\\RendererInterface\\:\\:getPerformanceData\\(\\)\\.$#"
405390
count: 1

rector.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
3333
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector;
3434
use Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector;
35-
use Rector\DeadCode\Rector\Plus\RemoveDeadZeroAndOneOperationRector;
3635
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
3736
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
3837
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
@@ -133,11 +132,11 @@
133132
__DIR__ . '/tests/system/Email/EmailTest.php',
134133
],
135134

136-
// buggy on read based on @var on property
137-
RemoveAlwaysTrueIfConditionRector::class,
138-
139-
// buggy on string * int
140-
RemoveDeadZeroAndOneOperationRector::class,
135+
// buggy on read based on @var on property on Trait
136+
RemoveAlwaysTrueIfConditionRector::class => [
137+
'**Trait.php',
138+
__DIR__ . '/system/Test/ControllerTester.php',
139+
],
141140
]);
142141

143142
// auto import fully qualified class names

system/Autoloader/Autoloader.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ public function register()
142142

143143
// Load our non-class files
144144
foreach ($this->files as $file) {
145-
if (is_string($file)) {
146-
$this->includeFile($file);
147-
}
145+
$this->includeFile($file);
148146
}
149147
}
150148

system/BaseModel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,11 @@ abstract protected function doFirst();
386386

387387
/**
388388
* Inserts data into the current database
389-
* This methods works only with dbCalls
389+
* This method works only with dbCalls
390390
*
391391
* @param array $data Data
392392
*
393-
* @return bool|int|string
393+
* @return bool
394394
*/
395395
abstract protected function doInsert(array $data);
396396

@@ -728,7 +728,7 @@ public function getInsertID()
728728
*
729729
* @throws ReflectionException
730730
*
731-
* @return bool|int|string
731+
* @return bool|int|string insert ID or true on success. false on failure.
732732
*/
733733
public function insert($data = null, bool $returnID = true)
734734
{

system/Cache/Handlers/MemcachedHandler.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ public function __construct(Cache $config)
4545
{
4646
$this->prefix = $config->prefix;
4747

48-
if (! empty($config)) {
49-
$this->config = array_merge($this->config, $config->memcached);
50-
}
48+
$this->config = array_merge($this->config, $config->memcached);
5149
}
5250

5351
/**

system/Cache/Handlers/RedisHandler.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ public function __construct(Cache $config)
4545
{
4646
$this->prefix = $config->prefix;
4747

48-
if (! empty($config)) {
49-
$this->config = array_merge($this->config, $config->redis);
50-
}
48+
$this->config = array_merge($this->config, $config->redis);
5149
}
5250

5351
/**

system/CodeIgniter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CodeIgniter
4747
/**
4848
* The current version of CodeIgniter Framework
4949
*/
50-
public const CI_VERSION = '4.2.1';
50+
public const CI_VERSION = '4.2.2';
5151

5252
/**
5353
* App startup time.

system/Database/BaseBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1879,7 +1879,7 @@ public function getCompiledInsert(bool $reset = true)
18791879
*
18801880
* @throws DatabaseException
18811881
*
1882-
* @return bool|Query
1882+
* @return bool
18831883
*/
18841884
public function insert($set = null, ?bool $escape = null)
18851885
{

system/Database/Forge.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ public function modifyColumn(string $table, $field): bool
764764
return false;
765765
}
766766

767-
if ($sqls !== null) {
767+
if (is_array($sqls)) {
768768
foreach ($sqls as $sql) {
769769
if ($this->db->query($sql) === false) {
770770
return false;

system/Debug/Exceptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ protected function collectVars(Throwable $exception, int $statusCode): array
269269
'title' => get_class($exception),
270270
'type' => get_class($exception),
271271
'code' => $statusCode,
272-
'message' => $exception->getMessage() ?? '(null)',
272+
'message' => $exception->getMessage(),
273273
'file' => $exception->getFile(),
274274
'line' => $exception->getLine(),
275275
'trace' => $trace,

system/Helpers/form_helper.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,8 @@ function form_open(string $action = '', $attributes = [], array $hidden = []): s
6363
$form .= csrf_field($csrfId ?? null);
6464
}
6565

66-
if (is_array($hidden)) {
67-
foreach ($hidden as $name => $value) {
68-
$form .= form_hidden($name, $value);
69-
}
66+
foreach ($hidden as $name => $value) {
67+
$form .= form_hidden($name, $value);
7068
}
7169

7270
return $form;

system/Helpers/text_helper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,12 @@ function random_string(string $type = 'alnum', int $len = 8): string
573573
return sha1(uniqid((string) mt_rand(), true));
574574

575575
case 'crypto':
576+
if ($len % 2 !== 0) {
577+
throw new InvalidArgumentException(
578+
'You must set an even number to the second parameter when you use `crypto`.'
579+
);
580+
}
581+
576582
return bin2hex(random_bytes($len / 2));
577583
}
578584
// 'basic' type treated as default

system/Model.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,11 @@ protected function doFirst()
251251

252252
/**
253253
* Inserts data into the current table.
254-
* This methods works only with dbCalls
254+
* This method works only with dbCalls
255255
*
256256
* @param array $data Data
257257
*
258-
* @return bool|Query
258+
* @return bool
259259
*/
260260
protected function doInsert(array $data)
261261
{

system/RESTful/ResourceController.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter\RESTful;
1313

1414
use CodeIgniter\API\ResponseTrait;
15+
use CodeIgniter\HTTP\Response;
1516

1617
/**
1718
* An extendable controller to provide a RESTful API for a resource.
@@ -23,7 +24,7 @@ class ResourceController extends BaseResource
2324
/**
2425
* Return an array of resource objects, themselves in array format
2526
*
26-
* @return mixed
27+
* @return Response|string|void
2728
*/
2829
public function index()
2930
{
@@ -33,9 +34,9 @@ public function index()
3334
/**
3435
* Return the properties of a resource object
3536
*
36-
* @param mixed $id
37+
* @param int|string|null $id
3738
*
38-
* @return mixed
39+
* @return Response|string|void
3940
*/
4041
public function show($id = null)
4142
{
@@ -45,7 +46,7 @@ public function show($id = null)
4546
/**
4647
* Return a new resource object, with default properties
4748
*
48-
* @return mixed
49+
* @return Response|string|void
4950
*/
5051
public function new()
5152
{
@@ -55,7 +56,7 @@ public function new()
5556
/**
5657
* Create a new resource object, from "posted" parameters
5758
*
58-
* @return mixed
59+
* @return Response|string|void
5960
*/
6061
public function create()
6162
{
@@ -65,9 +66,9 @@ public function create()
6566
/**
6667
* Return the editable properties of a resource object
6768
*
68-
* @param mixed $id
69+
* @param int|string|null $id
6970
*
70-
* @return mixed
71+
* @return Response|string|void
7172
*/
7273
public function edit($id = null)
7374
{
@@ -77,9 +78,9 @@ public function edit($id = null)
7778
/**
7879
* Add or update a model resource, from "posted" properties
7980
*
80-
* @param mixed $id
81+
* @param string|null|int$id
8182
*
82-
* @return mixed
83+
* @return Response|string|void
8384
*/
8485
public function update($id = null)
8586
{
@@ -89,9 +90,9 @@ public function update($id = null)
8990
/**
9091
* Delete the designated resource object from the model
9192
*
92-
* @param mixed $id
93+
* @param int|string|null $id
9394
*
94-
* @return mixed
95+
* @return Response|string|void
9596
*/
9697
public function delete($id = null)
9798
{
@@ -100,6 +101,8 @@ public function delete($id = null)
100101

101102
/**
102103
* Set/change the expected response representation for returned objects
104+
*
105+
* @return void
103106
*/
104107
public function setFormat(string $format = 'json')
105108
{

0 commit comments

Comments
 (0)