Skip to content

Commit 37dd49c

Browse files
authored
Merge pull request #475 from michalsn/update-460
Update framework to v4.6.0
2 parents b8b623c + 8e76d72 commit 37dd49c

21 files changed

+763
-648
lines changed

.github/workflows/infection.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Set up PHP
3232
uses: shivammathur/setup-php@v2
3333
with:
34-
php-version: '8.1'
34+
php-version: '8.2'
3535
tools: infection, phpunit
3636
extensions: intl, json, mbstring, gd, xml, sqlite3
3737
coverage: xdebug

app/Config/Boot/development.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/*
34
|--------------------------------------------------------------------------
45
| ERROR DISPLAY

app/Config/Cache.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,6 @@ class Cache extends BaseConfig
3434
*/
3535
public string $backupHandler = 'dummy';
3636

37-
/**
38-
* --------------------------------------------------------------------------
39-
* Cache Directory Path
40-
* --------------------------------------------------------------------------
41-
*
42-
* The path to where cache files should be stored, if using a file-based
43-
* system.
44-
*
45-
* @deprecated Use the driver-specific variant under $file
46-
*/
47-
public string $storePath = WRITEPATH . 'cache/';
48-
4937
/**
5038
* --------------------------------------------------------------------------
5139
* Key Prefix
@@ -85,6 +73,7 @@ class Cache extends BaseConfig
8573
* --------------------------------------------------------------------------
8674
* File settings
8775
* --------------------------------------------------------------------------
76+
*
8877
* Your file storage preferences can be specified below, if you are using
8978
* the File driver.
9079
*
@@ -99,6 +88,7 @@ class Cache extends BaseConfig
9988
* -------------------------------------------------------------------------
10089
* Memcached settings
10190
* -------------------------------------------------------------------------
91+
*
10292
* Your Memcached servers can be specified below, if you are using
10393
* the Memcached drivers.
10494
*

app/Config/Constants.php

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,13 @@
6767
| https://tldp.org/LDP/abs/html/exitcodes.html
6868
|
6969
*/
70-
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
71-
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
72-
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
73-
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
74-
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
70+
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
71+
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
72+
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
73+
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
74+
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
7575
defined('EXIT_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
76-
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
77-
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
78-
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
79-
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code
80-
81-
/**
82-
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_LOW instead.
83-
*/
84-
define('EVENT_PRIORITY_LOW', 200);
85-
86-
/**
87-
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_NORMAL instead.
88-
*/
89-
define('EVENT_PRIORITY_NORMAL', 100);
90-
91-
/**
92-
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_HIGH instead.
93-
*/
94-
define('EVENT_PRIORITY_HIGH', 10);
76+
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
77+
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
78+
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
79+
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code

app/Config/Database.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class Database extends Config
4343
'failover' => [],
4444
'port' => 3306,
4545
'numberNative' => false,
46+
'foundRows' => false,
4647
'dateFormat' => [
4748
'date' => 'Y-m-d',
4849
'datetime' => 'Y-m-d H:i:s',
@@ -64,6 +65,7 @@ class Database extends Config
6465
// 'failover' => [],
6566
// 'foreignKeys' => true,
6667
// 'busyTimeout' => 1000,
68+
// 'synchronous' => null,
6769
// 'dateFormat' => [
6870
// 'date' => 'Y-m-d',
6971
// 'datetime' => 'Y-m-d H:i:s',

app/Config/Events.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
*/
4545
if (CI_DEBUG && ! is_cli()) {
4646
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
47-
Services::toolbar()->respond();
47+
service('toolbar')->respond();
4848
// Hot Reload route - for framework use on the hot reloader.
4949
if (ENVIRONMENT === 'development') {
50-
Services::routes()->get('__hot-reload', static function () {
50+
service('routes')->get('__hot-reload', static function (): void {
5151
(new HotReloader())->run();
5252
});
5353
}

app/Config/Feature.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
class Feature extends BaseConfig
1111
{
1212
/**
13-
* Use improved new auto routing instead of the default legacy version.
13+
* Use improved new auto routing instead of the legacy version.
1414
*/
15-
public bool $autoRoutesImproved = false;
15+
public bool $autoRoutesImproved = true;
1616

1717
/**
1818
* Use filter execution order in 4.4 or before.
@@ -26,4 +26,12 @@ class Feature extends BaseConfig
2626
* If false, `limit(0)` returns no records. (the behavior of 3.1.9 or later in version 3.x.)
2727
*/
2828
public bool $limitZeroAsAll = true;
29+
30+
/**
31+
* Use strict location negotiation.
32+
*
33+
* By default, the locale is selected based on a loose comparison of the language code (ISO 639-1)
34+
* Enabling strict comparison will also consider the region code (ISO 3166-1 alpha-2).
35+
*/
36+
public bool $strictLocaleNegotiation = false;
2937
}

app/Config/Format.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Config;
44

55
use CodeIgniter\Config\BaseConfig;
6-
use CodeIgniter\Format\FormatterInterface;
76
use CodeIgniter\Format\JSONFormatter;
87
use CodeIgniter\Format\XMLFormatter;
98

@@ -62,16 +61,4 @@ class Format extends BaseConfig
6261
'application/xml' => 0,
6362
'text/xml' => 0,
6463
];
65-
66-
/**
67-
* A Factory method to return the appropriate formatter for the given mime type.
68-
*
69-
* @return FormatterInterface
70-
*
71-
* @deprecated This is an alias of `\CodeIgniter\Format\Format::getFormatter`. Use that instead.
72-
*/
73-
public function getFormatter(string $mime)
74-
{
75-
return Services::format()->getFormatter($mime);
76-
}
7764
}

app/Config/Kint.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Config;
44

55
use Kint\Parser\ConstructablePluginInterface;
6-
use Kint\Renderer\AbstractRenderer;
76
use Kint\Renderer\Rich\TabPluginInterface;
87
use Kint\Renderer\Rich\ValuePluginInterface;
98

@@ -41,7 +40,6 @@ class Kint
4140
*/
4241
public string $richTheme = 'aante-light.css';
4342
public bool $richFolder = false;
44-
public int $richSort = AbstractRenderer::SORT_FULL;
4543

4644
/**
4745
* @var array<string, class-string<ValuePluginInterface>>|null

app/Config/Routing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,5 @@ class Routing extends BaseRouting
136136
*
137137
* Default: false
138138
*/
139-
public bool $translateUriToCamelCase = false;
139+
public bool $translateUriToCamelCase = true;
140140
}

app/Config/Security.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,4 @@ class Security extends BaseConfig
8383
* @see https://codeigniter4.github.io/userguide/libraries/security.html#redirection-on-failure
8484
*/
8585
public bool $redirect = (ENVIRONMENT === 'production');
86-
87-
/**
88-
* --------------------------------------------------------------------------
89-
* CSRF SameSite
90-
* --------------------------------------------------------------------------
91-
*
92-
* Setting for CSRF SameSite cookie token.
93-
*
94-
* Allowed values are: None - Lax - Strict - ''.
95-
*
96-
* Defaults to `Lax` as recommended in this link:
97-
*
98-
* @see https://portswigger.net/web-security/csrf/samesite-cookies
99-
*
100-
* @deprecated `Config\Cookie` $samesite property is used.
101-
*/
102-
public string $samesite = 'Lax';
10386
}

app/Helpers/video_helper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* embedVideo ()
45
* -----------------------------------------------------------------------
@@ -36,7 +37,7 @@ function embedVideo(string $code, string $width = '640', string $height = '385')
3637
$code = $result['v'] ?? null;
3738
}
3839

39-
if (isset($code) && ! empty($code)) {
40+
if (! in_array($code, ['', null, '0', []], true)) {
4041
return '
4142
<iframe width="' . $width . '" height="' . $height . '"
4243
src="https://www.youtube.com/embed/' . $code . '" frameborder="0"

app/Libraries/Blog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ protected function parseVideoTags(?string $html = null)
295295
// Since the plugin doesn't support video embeds, yet,
296296
// wire our own up. The syntax for video embeds is
297297
// ![[ https://youtube.com/watch?v=xlkjsdfhlk ]]
298-
preg_match_all('|!video\[([\s\w:/.?=&;]*)\]|i', $html, $matches);
298+
$result = preg_match_all('|!video\[([\s\w:/.?=&;]*)\]|i', $html, $matches);
299299

300-
if ($matches === []) {
300+
if ($result < 1) {
301301
return $html;
302302
}
303303

app/Views/download.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
</div>
1313
</div><!--cv-boxes-version end-->
1414
<div class="cv-boxes-content">
15-
<p>CodeIgniter 4 is the latest version of the framework, intended for use with PHP 7.4+ (including 8.2).</p>
16-
<p>The initial release was February 24, 2020. The current version is <?= $v4name ?>. </p>
15+
<p>CodeIgniter 4 is the latest version of the framework, intended for use with PHP 8.1+ (including 8.4).</p>
16+
<p>The initial release was February 24, 2020. The current version is <?= esc($v4name) ?>. </p>
1717
<p>
1818
You *could* download this version of the framework using the button below, but we encourage you to check the
1919
<a href="https://codeigniter.com/user_guide/installation/index.html" class="link-primary" target="_blank">Installation section</a>

app/Views/errors/cli/error_exception.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
$function .= $padClass . $error['function'];
5151
}
5252

53-
$args = implode(', ', array_map(static fn ($value) => match (true) {
53+
$args = implode(', ', array_map(static fn ($value): string => match (true) {
5454
is_object($value) => 'Object(' . $value::class . ')',
55-
is_array($value) => count($value) ? '[...]' : '[]',
55+
is_array($value) => $value !== [] ? '[...]' : '[]',
5656
$value === null => 'null', // return the lowercased version
5757
default => var_export($value, true),
5858
}, array_values($error['args'] ?? [])));

app/Views/errors/html/debug.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ p.lead {
4141
.header {
4242
background: var(--light-bg-color);
4343
color: var(--dark-text-color);
44+
margin-top: 2.17rem;
4445
}
4546
.header .container {
4647
padding: 1rem;
@@ -65,10 +66,13 @@ p.lead {
6566
}
6667

6768
.environment {
68-
background: var(--dark-bg-color);
69-
color: var(--light-text-color);
69+
background: var(--brand-primary-color);
70+
color: var(--main-bg-color);
7071
text-align: center;
71-
padding: 0.2rem;
72+
padding: calc(4px + 0.2083vw);
73+
width: 100%;
74+
margin-top: -2.14rem;
75+
position: fixed;
7276
}
7377

7478
.source {

app/Views/errors/html/error_400.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title><?= lang('Errors.badRequest') ?></title>
6+
7+
<style>
8+
div.logo {
9+
height: 200px;
10+
width: 155px;
11+
display: inline-block;
12+
opacity: 0.08;
13+
position: absolute;
14+
top: 2rem;
15+
left: 50%;
16+
margin-left: -73px;
17+
}
18+
body {
19+
height: 100%;
20+
background: #fafafa;
21+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
22+
color: #777;
23+
font-weight: 300;
24+
}
25+
h1 {
26+
font-weight: lighter;
27+
letter-spacing: normal;
28+
font-size: 3rem;
29+
margin-top: 0;
30+
margin-bottom: 0;
31+
color: #222;
32+
}
33+
.wrap {
34+
max-width: 1024px;
35+
margin: 5rem auto;
36+
padding: 2rem;
37+
background: #fff;
38+
text-align: center;
39+
border: 1px solid #efefef;
40+
border-radius: 0.5rem;
41+
position: relative;
42+
}
43+
pre {
44+
white-space: normal;
45+
margin-top: 1.5rem;
46+
}
47+
code {
48+
background: #fafafa;
49+
border: 1px solid #efefef;
50+
padding: 0.5rem 1rem;
51+
border-radius: 5px;
52+
display: block;
53+
}
54+
p {
55+
margin-top: 1.5rem;
56+
}
57+
.footer {
58+
margin-top: 2rem;
59+
border-top: 1px solid #efefef;
60+
padding: 1em 2em 0 2em;
61+
font-size: 85%;
62+
color: #999;
63+
}
64+
a:active,
65+
a:link,
66+
a:visited {
67+
color: #dd4814;
68+
}
69+
</style>
70+
</head>
71+
<body>
72+
<div class="wrap">
73+
<h1>400</h1>
74+
75+
<p>
76+
<?php if (ENVIRONMENT !== 'production') : ?>
77+
<?= nl2br(esc($message)) ?>
78+
<?php else : ?>
79+
<?= lang('Errors.sorryBadRequest') ?>
80+
<?php endif; ?>
81+
</p>
82+
</div>
83+
</body>
84+
</html>

app/Views/errors/html/error_exception.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22
use CodeIgniter\HTTP\Header;
3-
use Config\Services;
43
use CodeIgniter\CodeIgniter;
54

65
$errorId = uniqid('error', true);
@@ -225,7 +224,7 @@
225224

226225
<!-- Request -->
227226
<div class="content" id="request">
228-
<?php $request = Services::request(); ?>
227+
<?php $request = service('request'); ?>
229228

230229
<table>
231230
<tbody>
@@ -343,7 +342,7 @@
343342

344343
<!-- Response -->
345344
<?php
346-
$response = Services::response();
345+
$response = service('response');
347346
$response->setStatusCode(http_response_code());
348347
?>
349348
<div class="content" id="response">

0 commit comments

Comments
 (0)