Skip to content

Commit 7f556d5

Browse files
committed
Merge remote-tracking branch 'origin/develop' into 4.5
2 parents 785995a + 4b71437 commit 7f556d5

File tree

19 files changed

+179
-40
lines changed

19 files changed

+179
-40
lines changed

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
# Changelog
22

3-
## [v4.4.2](https://github.com/codeigniter4/CodeIgniter4/tree/v4.4.1) (2023-10-19)
3+
## [v4.4.3](https://github.com/codeigniter4/CodeIgniter4/tree/v4.4.3) (2023-10-26)
4+
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.4.2...v4.4.3)
5+
6+
### SECURITY
7+
8+
* *Detailed Error Report is Displayed in Production Environment* was fixed. See the [Security advisory](https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-hwxf-qxj7-7rfj) for more information.
9+
10+
### Fixed Bugs
11+
12+
* fix: FilterTestTrait::getFilterCaller() does not support Filter classes as array by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8058
13+
* fix: add dbgroup to model template only when specified as an option by @sammyskills in https://github.com/codeigniter4/CodeIgniter4/pull/8077
14+
* Update phpstan-codeigniter and fix errors on Modules by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/8036
15+
* fix: [Validation] exact_length does not pass int values by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8088
16+
* fix: [Table] field named `data` will produce bugged output by @ping-yee in https://github.com/codeigniter4/CodeIgniter4/pull/8054
17+
* docs: fix event points descriptions by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8076
18+
* docs: fix helper loading by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8084
19+
20+
## [v4.4.2](https://github.com/codeigniter4/CodeIgniter4/tree/v4.4.2) (2023-10-19)
421
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.4.1...v4.4.2)
522

623
### Fixed Bugs

app/Config/Boot/development.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
| In development, we want to show as many errors as possible to help
88
| make sure they don't make it to production. And save us hours of
99
| painful debugging.
10+
|
11+
| If you set 'display_errors' to '1', CI4's detailed error report will show.
1012
*/
1113
error_reporting(-1);
1214
ini_set('display_errors', '1');

app/Config/Boot/production.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
|--------------------------------------------------------------------------
77
| Don't show ANY in production environments. Instead, let the system catch
88
| it and display a generic error message.
9+
|
10+
| If you set 'display_errors' to '1', CI4's detailed error report will show.
911
*/
1012
ini_set('display_errors', '0');
1113
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);

app/Config/Boot/testing.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<?php
22

3+
/*
4+
* The environment testing is reserved for PHPUnit testing. It has special
5+
* conditions built into the framework at various places to assist with that.
6+
* You can’t use it for your development.
7+
*/
8+
39
/*
410
|--------------------------------------------------------------------------
511
| ERROR DISPLAY

app/Views/errors/html/error_404.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<?= nl2br(esc($message)) ?>
7878
<?php else : ?>
7979
<?= lang('Errors.sorryCannotFind') ?>
80-
<?php endif ?>
80+
<?php endif; ?>
8181
</p>
8282
</div>
8383
</body>

app/Views/errors/html/error_exception.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<?php endif; ?>
4545
</div>
4646

47+
<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) : ?>
4748
<div class="container">
4849

4950
<ul class="tabs" id="tabs">
@@ -66,7 +67,7 @@
6667
<li>
6768
<p>
6869
<!-- Trace info -->
69-
<?php if (isset($row['file']) && is_file($row['file'])) :?>
70+
<?php if (isset($row['file']) && is_file($row['file'])) : ?>
7071
<?php
7172
if (isset($row['function']) && in_array($row['function'], ['include', 'include_once', 'require', 'require_once'], true)) {
7273
echo esc($row['function'] . ' ' . clean_path($row['file']));
@@ -375,14 +376,16 @@
375376
</div> <!-- /tab-content -->
376377

377378
</div> <!-- /container -->
379+
<?php endif; ?>
378380

379381
<div class="footer">
380382
<div class="container">
381383

382384
<p>
383385
Displayed at <?= esc(date('H:i:sa')) ?> &mdash;
384386
PHP: <?= esc(PHP_VERSION) ?> &mdash;
385-
CodeIgniter: <?= esc(CodeIgniter::CI_VERSION) ?>
387+
CodeIgniter: <?= esc(CodeIgniter::CI_VERSION) ?> --
388+
Environment: <?= ENVIRONMENT ?>
386389
</p>
387390

388391
</div>

system/CodeIgniter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class CodeIgniter
5454
/**
5555
* The current version of CodeIgniter Framework
5656
*/
57-
public const CI_VERSION = '4.4.2';
57+
public const CI_VERSION = '4.4.3';
5858

5959
/**
6060
* App startup time.

system/Config/BaseConfig.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ public static function setModules(Modules $modules): void
8383
static::$moduleConfig = $modules;
8484
}
8585

86+
/**
87+
* @internal For testing purposes only.
88+
* @testTag
89+
*/
90+
public static function reset(): void
91+
{
92+
static::$registrars = [];
93+
static::$override = true;
94+
static::$didDiscovery = false;
95+
static::$moduleConfig = null;
96+
}
97+
8698
/**
8799
* Will attempt to get environment variables with names
88100
* that match the properties of the child class.

system/Debug/ExceptionHandler.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,13 @@ protected function determineView(Throwable $exception, string $templatePath): st
129129
// Production environments should have a custom exception file.
130130
$view = 'production.php';
131131

132-
if (str_ireplace(['off', 'none', 'no', 'false', 'null'], '', ini_get('display_errors')) !== '') {
132+
if (
133+
in_array(
134+
strtolower(ini_get('display_errors')),
135+
['1', 'true', 'on', 'yes'],
136+
true
137+
)
138+
) {
133139
$view = 'error_exception.php';
134140
}
135141

system/Debug/Exceptions.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,13 @@ protected function determineView(Throwable $exception, string $templatePath): st
253253
$view = 'production.php';
254254
$templatePath = rtrim($templatePath, '\\/ ') . DIRECTORY_SEPARATOR;
255255

256-
if (str_ireplace(['off', 'none', 'no', 'false', 'null'], '', ini_get('display_errors')) !== '') {
256+
if (
257+
in_array(
258+
strtolower(ini_get('display_errors')),
259+
['1', 'true', 'on', 'yes'],
260+
true
261+
)
262+
) {
257263
$view = 'error_exception.php';
258264
}
259265

system/View/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ protected function _prepArgs(array $args)
265265
// If there is no $args[0], skip this and treat as an associative array
266266
// This can happen if there is only a single key, for example this is passed to table->generate
267267
// array(array('foo'=>'bar'))
268-
if (isset($args[0]) && count($args) === 1 && is_array($args[0]) && ! isset($args[0]['data'])) {
268+
if (isset($args[0]) && count($args) === 1 && is_array($args[0])) {
269269
$args = $args[0];
270270
}
271271

tests/system/Config/BaseConfigTest.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,17 @@ protected function setUp(): void
4949
require $this->fixturesFolder . '/Encryption.php';
5050
}
5151

52-
BaseConfig::$registrars = [];
53-
BaseConfig::setModules(new Modules()); // reset to clean copy of Modules
52+
BaseConfig::reset();
53+
}
54+
55+
protected function tearDown(): void
56+
{
57+
parent::tearDown();
58+
59+
// This test modifies BaseConfig::$modules, so should reset.
60+
BaseConfig::reset();
61+
// This test modifies Services locator, so should reset.
62+
$this->resetServices();
5463
}
5564

5665
public function testBasicValues(): void
@@ -271,18 +280,24 @@ public function testBadRegistrar(): void
271280
$this->assertSame('bar', $config->foo);
272281
}
273282

283+
/**
284+
* @psalm-suppress UndefinedClass
285+
*/
274286
public function testDiscoveryNotEnabledWillNotPopulateRegistrarsArray(): void
275287
{
276288
/** @var MockObject&Modules $modules */
277289
$modules = $this->createMock(Modules::class);
278290
$modules->method('shouldDiscover')->with('registrars')->willReturn(false);
279-
280291
RegistrarConfig::setModules($modules);
292+
281293
$config = new RegistrarConfig();
282294

283295
$this->assertSame([], $config::$registrars);
284296
}
285297

298+
/**
299+
* @psalm-suppress UndefinedClass
300+
*/
286301
public function testRedoingDiscoveryWillStillSetDidDiscoveryPropertyToTrue(): void
287302
{
288303
/** @var FileLocator&MockObject $locator */

tests/system/Debug/ExceptionHandlerTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@ public function testDetermineViewsRuntimeExceptionCode404(): void
7070
$this->assertSame('error_404.php', $viewFile);
7171
}
7272

73+
public function testDetermineViewsDisplayErrorsOffRuntimeException(): void
74+
{
75+
ini_set('display_errors', '0');
76+
77+
$determineView = $this->getPrivateMethodInvoker($this->handler, 'determineView');
78+
79+
$exception = new RuntimeException('Exception');
80+
$templatePath = APPPATH . 'Views/errors/html';
81+
$viewFile = $determineView($exception, $templatePath);
82+
83+
$this->assertSame('production.php', $viewFile);
84+
85+
ini_set('display_errors', '1');
86+
}
87+
7388
public function testCollectVars(): void
7489
{
7590
$collectVars = $this->getPrivateMethodInvoker($this->handler, 'collectVars');

tests/system/View/TableTest.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,64 @@ public static function orderedColumnUsecases(): iterable
816816
],
817817
];
818818
}
819+
820+
/**
821+
* @see https://github.com/codeigniter4/CodeIgniter4/issues/8051
822+
*/
823+
public function testGenerateTableWithHeadingContainFieldNamedData(): void
824+
{
825+
$table = new Table();
826+
$table->setHeading([
827+
'codigo' => 'Codigo Orçamento',
828+
'data' => 'Data do Orçamento',
829+
'tipo_desconto' => 'Tipo de Desconto',
830+
'valor_desconto' => 'Valor do Desconto',
831+
])->setSyncRowsWithHeading(true);
832+
833+
$sampleData = [
834+
[
835+
'id' => 1,
836+
'id_cliente' => 1,
837+
'codigo' => 'codigo1',
838+
'data' => '2023-10-16 21:53:25',
839+
'tipo_desconto' => 'NENHUM',
840+
'valor_desconto' => '',
841+
'created_at' => '2023-10-16 21:53:25',
842+
'updated_at' => '2023-10-16 21:53:25',
843+
'deleted_at' => '',
844+
],
845+
[
846+
'id' => 2,
847+
'id_cliente' => 2,
848+
'codigo' => 'codigo2',
849+
'data' => '2023-10-16 21:53:25',
850+
'tipo_desconto' => 'REAL',
851+
'valor_desconto' => 10.00,
852+
'created_at' => '2023-10-16 21:53:25',
853+
'updated_at' => '2023-10-16 21:53:25',
854+
'deleted_at' => '',
855+
],
856+
[
857+
'id' => 3,
858+
'id_cliente' => 3,
859+
'codigo' => 'codigo3',
860+
'data' => '2023-10-16 21:53:25',
861+
'tipo_desconto' => 'PERCENTUAL',
862+
'valor_desconto' => 10.00,
863+
'created_at' => '2023-10-16 21:53:25',
864+
'updated_at' => '2023-10-16 21:53:25',
865+
'deleted_at' => '',
866+
],
867+
];
868+
869+
$generated = $table->generate($sampleData);
870+
871+
$this->assertStringContainsString('<th>Codigo Orçamento</th><th>Data do Orçamento</th><th>Tipo de Desconto</th><th>Valor do Desconto</th>', $generated);
872+
873+
$this->assertStringContainsString('<td>codigo1</td><td>2023-10-16 21:53:25</td><td>NENHUM</td><td></td>', $generated);
874+
$this->assertStringContainsString('<td>codigo2</td><td>2023-10-16 21:53:25</td><td>REAL</td><td>10</td>', $generated);
875+
$this->assertStringContainsString('<td>codigo3</td><td>2023-10-16 21:53:25</td><td>PERCENTUAL</td><td>10</td>', $generated);
876+
}
819877
}
820878

821879
// We need this for the _set_from_db_result() test

user_guide_src/source/changelogs/v4.4.3.rst

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
Version 4.4.3
22
#############
33

4-
Release Date: Unreleased
4+
Release Date: October 26, 2023
55

66
**4.4.3 release of CodeIgniter4**
77

88
.. contents::
99
:local:
1010
:depth: 3
1111

12-
BREAKING
12+
SECURITY
1313
********
1414

15-
Message Changes
16-
***************
17-
18-
Changes
19-
*******
20-
21-
Deprecations
22-
************
15+
- *Detailed Error Report is Displayed in Production Environment* was fixed.
16+
See the `Security advisory GHSA-hwxf-qxj7-7rfj <https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-hwxf-qxj7-7rfj>`_
17+
for more information.
2318

2419
Bugs Fixed
2520
**********

user_guide_src/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
version = '4.4'
2727

2828
# The full version, including alpha/beta/rc tags.
29-
release = '4.4.2'
29+
release = '4.4.3'
3030

3131
# -- General configuration ---------------------------------------------------
3232

user_guide_src/source/general/environments.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ By default, CodeIgniter has three environments defined.
3030
If you want another environment, e.g., for staging, you can add custom environments.
3131
See `Adding Environments`_.
3232

33+
.. _setting-environment:
34+
3335
*******************
3436
Setting Environment
3537
*******************

user_guide_src/source/general/errors.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ Error Reporting
4949
---------------
5050

5151
By default, CodeIgniter will display a detailed error report with all errors in the ``development`` and ``testing`` environments, and will not
52-
display any errors in the ``production`` environment. You can change this by setting the ``CI_ENVIRONMENT`` variable
53-
in the :ref:`.env <dotenv-file>` file.
52+
display any errors in the ``production`` environment.
53+
54+
.. image:: ../images/error.png
55+
56+
You can change your environment by setting the ``CI_ENVIRONMENT`` variable.
57+
See :ref:`setting-environment`.
5458

5559
.. important:: Disabling error reporting DOES NOT stop logs from being written if there are errors.
5660

0 commit comments

Comments
 (0)