Skip to content

Update framework to v4.6.0 #475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/infection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: infection, phpunit
extensions: intl, json, mbstring, gd, xml, sqlite3
coverage: xdebug
Expand Down
1 change: 1 addition & 0 deletions app/Config/Boot/development.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
Expand Down
14 changes: 2 additions & 12 deletions app/Config/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ class Cache extends BaseConfig
*/
public string $backupHandler = 'dummy';

/**
* --------------------------------------------------------------------------
* Cache Directory Path
* --------------------------------------------------------------------------
*
* The path to where cache files should be stored, if using a file-based
* system.
*
* @deprecated Use the driver-specific variant under $file
*/
public string $storePath = WRITEPATH . 'cache/';

/**
* --------------------------------------------------------------------------
* Key Prefix
Expand Down Expand Up @@ -85,6 +73,7 @@ class Cache extends BaseConfig
* --------------------------------------------------------------------------
* File settings
* --------------------------------------------------------------------------
*
* Your file storage preferences can be specified below, if you are using
* the File driver.
*
Expand All @@ -99,6 +88,7 @@ class Cache extends BaseConfig
* -------------------------------------------------------------------------
* Memcached settings
* -------------------------------------------------------------------------
*
* Your Memcached servers can be specified below, if you are using
* the Memcached drivers.
*
Expand Down
33 changes: 9 additions & 24 deletions app/Config/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,13 @@
| https://tldp.org/LDP/abs/html/exitcodes.html
|
*/
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
defined('EXIT_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code

/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_LOW instead.
*/
define('EVENT_PRIORITY_LOW', 200);

/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_NORMAL instead.
*/
define('EVENT_PRIORITY_NORMAL', 100);

/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_HIGH instead.
*/
define('EVENT_PRIORITY_HIGH', 10);
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code
2 changes: 2 additions & 0 deletions app/Config/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Database extends Config
'failover' => [],
'port' => 3306,
'numberNative' => false,
'foundRows' => false,
'dateFormat' => [
'date' => 'Y-m-d',
'datetime' => 'Y-m-d H:i:s',
Expand All @@ -64,6 +65,7 @@ class Database extends Config
// 'failover' => [],
// 'foreignKeys' => true,
// 'busyTimeout' => 1000,
// 'synchronous' => null,
// 'dateFormat' => [
// 'date' => 'Y-m-d',
// 'datetime' => 'Y-m-d H:i:s',
Expand Down
4 changes: 2 additions & 2 deletions app/Config/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
*/
if (CI_DEBUG && ! is_cli()) {
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
Services::toolbar()->respond();
service('toolbar')->respond();
// Hot Reload route - for framework use on the hot reloader.
if (ENVIRONMENT === 'development') {
Services::routes()->get('__hot-reload', static function () {
service('routes')->get('__hot-reload', static function (): void {
(new HotReloader())->run();
});
}
Expand Down
12 changes: 10 additions & 2 deletions app/Config/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
class Feature extends BaseConfig
{
/**
* Use improved new auto routing instead of the default legacy version.
* Use improved new auto routing instead of the legacy version.
*/
public bool $autoRoutesImproved = false;
public bool $autoRoutesImproved = true;

/**
* Use filter execution order in 4.4 or before.
Expand All @@ -26,4 +26,12 @@ class Feature extends BaseConfig
* If false, `limit(0)` returns no records. (the behavior of 3.1.9 or later in version 3.x.)
*/
public bool $limitZeroAsAll = true;

/**
* Use strict location negotiation.
*
* By default, the locale is selected based on a loose comparison of the language code (ISO 639-1)
* Enabling strict comparison will also consider the region code (ISO 3166-1 alpha-2).
*/
public bool $strictLocaleNegotiation = false;
}
13 changes: 0 additions & 13 deletions app/Config/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Config;

use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Format\FormatterInterface;
use CodeIgniter\Format\JSONFormatter;
use CodeIgniter\Format\XMLFormatter;

Expand Down Expand Up @@ -62,16 +61,4 @@ class Format extends BaseConfig
'application/xml' => 0,
'text/xml' => 0,
];

/**
* A Factory method to return the appropriate formatter for the given mime type.
*
* @return FormatterInterface
*
* @deprecated This is an alias of `\CodeIgniter\Format\Format::getFormatter`. Use that instead.
*/
public function getFormatter(string $mime)
{
return Services::format()->getFormatter($mime);
}
}
2 changes: 0 additions & 2 deletions app/Config/Kint.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Config;

use Kint\Parser\ConstructablePluginInterface;
use Kint\Renderer\AbstractRenderer;
use Kint\Renderer\Rich\TabPluginInterface;
use Kint\Renderer\Rich\ValuePluginInterface;

Expand Down Expand Up @@ -41,7 +40,6 @@ class Kint
*/
public string $richTheme = 'aante-light.css';
public bool $richFolder = false;
public int $richSort = AbstractRenderer::SORT_FULL;

/**
* @var array<string, class-string<ValuePluginInterface>>|null
Expand Down
2 changes: 1 addition & 1 deletion app/Config/Routing.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,5 @@ class Routing extends BaseRouting
*
* Default: false
*/
public bool $translateUriToCamelCase = false;
public bool $translateUriToCamelCase = true;
}
17 changes: 0 additions & 17 deletions app/Config/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,4 @@ class Security extends BaseConfig
* @see https://codeigniter4.github.io/userguide/libraries/security.html#redirection-on-failure
*/
public bool $redirect = (ENVIRONMENT === 'production');

/**
* --------------------------------------------------------------------------
* CSRF SameSite
* --------------------------------------------------------------------------
*
* Setting for CSRF SameSite cookie token.
*
* Allowed values are: None - Lax - Strict - ''.
*
* Defaults to `Lax` as recommended in this link:
*
* @see https://portswigger.net/web-security/csrf/samesite-cookies
*
* @deprecated `Config\Cookie` $samesite property is used.
*/
public string $samesite = 'Lax';
}
3 changes: 2 additions & 1 deletion app/Helpers/video_helper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* embedVideo ()
* -----------------------------------------------------------------------
Expand Down Expand Up @@ -36,7 +37,7 @@ function embedVideo(string $code, string $width = '640', string $height = '385')
$code = $result['v'] ?? null;
}

if (isset($code) && ! empty($code)) {
if (! in_array($code, ['', null, '0', []], true)) {
return '
<iframe width="' . $width . '" height="' . $height . '"
src="https://www.youtube.com/embed/' . $code . '" frameborder="0"
Expand Down
4 changes: 2 additions & 2 deletions app/Libraries/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,16 @@
*
* @return list<string>|string|null
*/
protected function parseVideoTags(?string $html = null)

Check warning on line 291 in app/Libraries/Blog.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "ProtectedVisibility": @@ @@ * * @return list<string>|string|null */ - protected function parseVideoTags(?string $html = null) + private function parseVideoTags(?string $html = null) { helper('video'); // Since the plugin doesn't support video embeds, yet,
{
helper('video');

// Since the plugin doesn't support video embeds, yet,
// wire our own up. The syntax for video embeds is
// ![[ https://youtube.com/watch?v=xlkjsdfhlk ]]
preg_match_all('|!video\[([\s\w:/.?=&;]*)\]|i', $html, $matches);
$result = preg_match_all('|!video\[([\s\w:/.?=&;]*)\]|i', $html, $matches);

if ($matches === []) {
if ($result < 1) {

Check warning on line 300 in app/Libraries/Blog.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "LessThanNegotiation": @@ @@ // wire our own up. The syntax for video embeds is // ![[ https://youtube.com/watch?v=xlkjsdfhlk ]] $result = preg_match_all('|!video\\[([\\s\\w:/.?=&;]*)\\]|i', $html, $matches); - if ($result < 1) { + if ($result >= 1) { return $html; } for ($i = 0; $i < count($matches) - 1; $i++) {

Check warning on line 300 in app/Libraries/Blog.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "LessThan": @@ @@ // wire our own up. The syntax for video embeds is // ![[ https://youtube.com/watch?v=xlkjsdfhlk ]] $result = preg_match_all('|!video\\[([\\s\\w:/.?=&;]*)\\]|i', $html, $matches); - if ($result < 1) { + if ($result <= 1) { return $html; } for ($i = 0; $i < count($matches) - 1; $i++) {
return $html;
}

Expand Down
4 changes: 2 additions & 2 deletions app/Views/download.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</div>
</div><!--cv-boxes-version end-->
<div class="cv-boxes-content">
<p>CodeIgniter 4 is the latest version of the framework, intended for use with PHP 7.4+ (including 8.2).</p>
<p>The initial release was February 24, 2020. The current version is <?= $v4name ?>. </p>
<p>CodeIgniter 4 is the latest version of the framework, intended for use with PHP 8.1+ (including 8.4).</p>
<p>The initial release was February 24, 2020. The current version is <?= esc($v4name) ?>. </p>
<p>
You *could* download this version of the framework using the button below, but we encourage you to check the
<a href="https://codeigniter.com/user_guide/installation/index.html" class="link-primary" target="_blank">Installation section</a>
Expand Down
4 changes: 2 additions & 2 deletions app/Views/errors/cli/error_exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
$function .= $padClass . $error['function'];
}

$args = implode(', ', array_map(static fn ($value) => match (true) {
$args = implode(', ', array_map(static fn ($value): string => match (true) {
is_object($value) => 'Object(' . $value::class . ')',
is_array($value) => count($value) ? '[...]' : '[]',
is_array($value) => $value !== [] ? '[...]' : '[]',
$value === null => 'null', // return the lowercased version
default => var_export($value, true),
}, array_values($error['args'] ?? [])));
Expand Down
10 changes: 7 additions & 3 deletions app/Views/errors/html/debug.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ p.lead {
.header {
background: var(--light-bg-color);
color: var(--dark-text-color);
margin-top: 2.17rem;
}
.header .container {
padding: 1rem;
Expand All @@ -65,10 +66,13 @@ p.lead {
}

.environment {
background: var(--dark-bg-color);
color: var(--light-text-color);
background: var(--brand-primary-color);
color: var(--main-bg-color);
text-align: center;
padding: 0.2rem;
padding: calc(4px + 0.2083vw);
width: 100%;
margin-top: -2.14rem;
position: fixed;
}

.source {
Expand Down
84 changes: 84 additions & 0 deletions app/Views/errors/html/error_400.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?= lang('Errors.badRequest') ?></title>

<style>
div.logo {
height: 200px;
width: 155px;
display: inline-block;
opacity: 0.08;
position: absolute;
top: 2rem;
left: 50%;
margin-left: -73px;
}
body {
height: 100%;
background: #fafafa;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #777;
font-weight: 300;
}
h1 {
font-weight: lighter;
letter-spacing: normal;
font-size: 3rem;
margin-top: 0;
margin-bottom: 0;
color: #222;
}
.wrap {
max-width: 1024px;
margin: 5rem auto;
padding: 2rem;
background: #fff;
text-align: center;
border: 1px solid #efefef;
border-radius: 0.5rem;
position: relative;
}
pre {
white-space: normal;
margin-top: 1.5rem;
}
code {
background: #fafafa;
border: 1px solid #efefef;
padding: 0.5rem 1rem;
border-radius: 5px;
display: block;
}
p {
margin-top: 1.5rem;
}
.footer {
margin-top: 2rem;
border-top: 1px solid #efefef;
padding: 1em 2em 0 2em;
font-size: 85%;
color: #999;
}
a:active,
a:link,
a:visited {
color: #dd4814;
}
</style>
</head>
<body>
<div class="wrap">
<h1>400</h1>

<p>
<?php if (ENVIRONMENT !== 'production') : ?>
<?= nl2br(esc($message)) ?>
<?php else : ?>
<?= lang('Errors.sorryBadRequest') ?>
<?php endif; ?>
</p>
</div>
</body>
</html>
5 changes: 2 additions & 3 deletions app/Views/errors/html/error_exception.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
use CodeIgniter\HTTP\Header;
use Config\Services;
use CodeIgniter\CodeIgniter;

$errorId = uniqid('error', true);
Expand Down Expand Up @@ -225,7 +224,7 @@

<!-- Request -->
<div class="content" id="request">
<?php $request = Services::request(); ?>
<?php $request = service('request'); ?>

<table>
<tbody>
Expand Down Expand Up @@ -343,7 +342,7 @@

<!-- Response -->
<?php
$response = Services::response();
$response = service('response');
$response->setStatusCode(http_response_code());
?>
<div class="content" id="response">
Expand Down
Loading
Loading