Skip to content

Commit f65a2cf

Browse files
committed
Release v4.2.1
1 parent 29f0e9e commit f65a2cf

File tree

23 files changed

+123
-58
lines changed

23 files changed

+123
-58
lines changed

app/Config/Mimes.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ class Mimes
102102
],
103103
'pptx' => [
104104
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
105-
'application/x-zip',
106-
'application/zip',
107105
],
108106
'wbxml' => 'application/wbxml',
109107
'wmlc' => 'application/wmlc',
@@ -512,20 +510,19 @@ public static function guessExtensionFromType(string $type, ?string $proposedExt
512510

513511
$proposedExtension = trim(strtolower($proposedExtension ?? ''));
514512

515-
if ($proposedExtension !== '') {
516-
if (array_key_exists($proposedExtension, static::$mimes) && in_array($type, is_string(static::$mimes[$proposedExtension]) ? [static::$mimes[$proposedExtension]] : static::$mimes[$proposedExtension], true)) {
517-
// The detected mime type matches with the proposed extension.
518-
return $proposedExtension;
519-
}
520-
521-
// An extension was proposed, but the media type does not match the mime type list.
522-
return null;
513+
if (
514+
$proposedExtension !== ''
515+
&& array_key_exists($proposedExtension, static::$mimes)
516+
&& in_array($type, (array) static::$mimes[$proposedExtension], true)
517+
) {
518+
// The detected mime type matches with the proposed extension.
519+
return $proposedExtension;
523520
}
524521

525522
// Reverse check the mime type list if no extension was proposed.
526523
// This search is order sensitive!
527524
foreach (static::$mimes as $ext => $types) {
528-
if ((is_string($types) && $types === $type) || (is_array($types) && in_array($type, $types, true))) {
525+
if (in_array($type, (array) $types, true)) {
529526
return $ext;
530527
}
531528
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"mikey179/vfsstream": "^1.6",
2222
"nexusphp/cs-config": "^3.3",
2323
"phpunit/phpunit": "^9.1",
24-
"predis/predis": "^1.1"
24+
"predis/predis": "^1.1 || ^2.0"
2525
},
2626
"suggest": {
2727
"ext-fileinfo": "Improves mime type detection for files"

system/Cache/Handlers/MemcachedHandler.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ public function initialize()
115115
} else {
116116
throw new CriticalError('Cache: Not support Memcache(d) extension.');
117117
}
118-
} catch (CriticalError $e) {
119-
throw $e;
120118
} catch (Exception $e) {
121119
throw new CriticalError('Cache: Memcache(d) connection refused (' . $e->getMessage() . ').');
122120
}

system/CodeIgniter.php

Lines changed: 2 additions & 4 deletions
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.0';
50+
public const CI_VERSION = '4.2.1';
5151

5252
private const MIN_PHP_VERSION = '7.4';
5353

@@ -256,9 +256,7 @@ protected function initializeKint()
256256
require_once SYSTEMPATH . 'ThirdParty/Kint/init.php';
257257
}
258258

259-
/**
260-
* Config\Kint
261-
*/
259+
/** @var \Config\Kint $config */
262260
$config = config(KintConfig::class);
263261

264262
Kint::$depth_limit = $config->maxDepth;

system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function get(): array
6565

6666
foreach ($finder->find() as $class) {
6767
// Exclude controllers in Defined Routes.
68-
if (in_array($class, $this->protectedControllers, true)) {
68+
if (in_array('\\' . $class, $this->protectedControllers, true)) {
6969
continue;
7070
}
7171

system/Cookie/Cookie.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ class Cookie implements ArrayAccess, CloneableCookieInterface
119119
* Set the default attributes to a Cookie instance by injecting
120120
* the values from the `CookieConfig` config or an array.
121121
*
122+
* This method is called from Response::__construct().
123+
*
122124
* @param array<string, mixed>|CookieConfig $config
123125
*
124126
* @return array<string, mixed> The old defaults array. Useful for resetting.
@@ -209,7 +211,7 @@ final public function __construct(string $name, string $value = '', array $optio
209211
}
210212

211213
// to preserve backward compatibility with array-based cookies in previous CI versions
212-
$prefix = $options['prefix'] ?: self::$defaults['prefix'];
214+
$prefix = ($options['prefix'] === '') ? self::$defaults['prefix'] : $options['prefix'];
213215
$path = $options['path'] ?: self::$defaults['path'];
214216
$domain = $options['domain'] ?: self::$defaults['domain'];
215217

system/Database/BaseBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@ protected function validateInsert(): bool
19231923
{
19241924
if (empty($this->QBSet)) {
19251925
if (CI_DEBUG) {
1926-
throw new DatabaseException('You must use the "set" method to update an entry.');
1926+
throw new DatabaseException('You must use the "set" method to insert an entry.');
19271927
}
19281928

19291929
return false; // @codeCoverageIgnore

system/Database/BaseConnection.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Closure;
1515
use CodeIgniter\Database\Exceptions\DatabaseException;
1616
use CodeIgniter\Events\Events;
17+
use Exception;
1718
use stdClass;
1819
use Throwable;
1920

@@ -603,7 +604,14 @@ public function query(string $sql, $binds = null, bool $setEscapeFlags = true, s
603604
$this->lastQuery = $query;
604605

605606
// Run the query for real
606-
if (! $this->pretend && false === ($this->resultID = $this->simpleQuery($query->getQuery()))) {
607+
try {
608+
$exception = null;
609+
$this->resultID = $this->simpleQuery($query->getQuery());
610+
} catch (Exception $exception) {
611+
$this->resultID = false;
612+
}
613+
614+
if (! $this->pretend && $this->resultID === false) {
607615
$query->setDuration($startTime, $startTime);
608616

609617
// This will trigger a rollback if transactions are being used
@@ -626,6 +634,15 @@ public function query(string $sql, $binds = null, bool $setEscapeFlags = true, s
626634
}
627635
}
628636

637+
if (! $this->pretend) {
638+
// Let others do something with this query.
639+
Events::trigger('DBQuery', $query);
640+
}
641+
642+
if ($exception !== null) {
643+
throw $exception;
644+
}
645+
629646
return false;
630647
}
631648

system/Database/MigrationRunner.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@ public function findMigrations(): array
402402
$migrations = [];
403403

404404
foreach ($namespaces as $namespace) {
405+
if (ENVIRONMENT !== 'testing' && $namespace === 'Tests\Support') {
406+
continue;
407+
}
408+
405409
foreach ($this->findNamespaceMigrations($namespace) as $migration) {
406410
$migrations[$migration->uid] = $migration;
407411
}

system/Debug/Toolbar/Views/toolbar.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@
303303
#debug-bar .ci-label img {
304304
margin: unset;
305305
}
306-
307306
.hide-sm {
308307
display: none !important;
309308
}
@@ -432,7 +431,6 @@
432431
#debug-icon a:visited {
433432
color: #DD8615;
434433
}
435-
436434
#debug-bar {
437435
background-color: #252525;
438436
color: #DFDFDF;
@@ -526,11 +524,9 @@
526524
#debug-bar .timeline .timer {
527525
background-color: #DD8615;
528526
}
529-
530527
.debug-view.show-view {
531528
border-color: #DD8615;
532529
}
533-
534530
.debug-view-path {
535531
background-color: #FDC894;
536532
color: #434343;

0 commit comments

Comments
 (0)