Skip to content

Commit 26ebf14

Browse files
committed
Release v4.2.5
1 parent f91bc95 commit 26ebf14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+511
-90
lines changed

composer.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"ext-intl": "*",
1111
"ext-json": "*",
1212
"ext-mbstring": "*",
13-
"kint-php/kint": "^4.1.1",
13+
"kint-php/kint": "^4.2",
1414
"laminas/laminas-escaper": "^2.9",
1515
"psr/log": "^1.1"
1616
},
@@ -24,7 +24,18 @@
2424
"predis/predis": "^1.1 || ^2.0"
2525
},
2626
"suggest": {
27-
"ext-fileinfo": "Improves mime type detection for files"
27+
"ext-imagick": "If you use Image class ImageMagickHandler",
28+
"ext-simplexml": "If you format XML",
29+
"ext-mysqli": "If you use MySQL",
30+
"ext-oci8": "If you use Oracle Database",
31+
"ext-pgsql": "If you use PostgreSQL",
32+
"ext-sqlsrv": "If you use SQL Server",
33+
"ext-sqlite3": "If you use SQLite3",
34+
"ext-memcache": "If you use Cache class MemcachedHandler with Memcache",
35+
"ext-memcached": "If you use Cache class MemcachedHandler with Memcached",
36+
"ext-redis": "If you use Cache class RedisHandler",
37+
"ext-fileinfo": "Improves mime type detection for files",
38+
"ext-readline": "Improves CLI::input() usability"
2839
},
2940
"autoload": {
3041
"psr-4": {

env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
# database.default.port = 3306
4949

5050
# database.tests.hostname = localhost
51-
# database.tests.database = ci4
51+
# database.tests.database = ci4_test
5252
# database.tests.username = root
5353
# database.tests.password = root
5454
# database.tests.DBDriver = MySQLi

system/CodeIgniter.php

Lines changed: 5 additions & 3 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.4';
50+
public const CI_VERSION = '4.2.5';
5151

5252
/**
5353
* App startup time.
@@ -982,8 +982,10 @@ protected function gatherOutput(?Cache $cacheConfig = null, $returned = null)
982982

983983
if ($returned instanceof DownloadResponse) {
984984
// Turn off output buffering completely, even if php.ini output_buffering is not off
985-
while (ob_get_level() > 0) {
986-
ob_end_clean();
985+
if (ENVIRONMENT !== 'testing') {
986+
while (ob_get_level() > 0) {
987+
ob_end_clean();
988+
}
987989
}
988990

989991
$this->response = $returned;

system/Commands/Cache/ClearCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ClearCache extends BaseCommand
4646
*
4747
* @var string
4848
*/
49-
protected $usage = 'cache:clear [driver]';
49+
protected $usage = 'cache:clear [<driver>]';
5050

5151
/**
5252
* the Command's Arguments

system/Commands/Help.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Help extends BaseCommand
4848
*
4949
* @var string
5050
*/
51-
protected $usage = 'help command_name';
51+
protected $usage = 'help [<command_name>]';
5252

5353
/**
5454
* the Command's Arguments

system/Common.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use CodeIgniter\Debug\Timer;
2020
use CodeIgniter\Files\Exceptions\FileNotFoundException;
2121
use CodeIgniter\HTTP\Exceptions\HTTPException;
22+
use CodeIgniter\HTTP\IncomingRequest;
2223
use CodeIgniter\HTTP\RedirectResponse;
2324
use CodeIgniter\HTTP\RequestInterface;
2425
use CodeIgniter\HTTP\ResponseInterface;
@@ -487,6 +488,10 @@ function force_https(int $duration = 31_536_000, ?RequestInterface $request = nu
487488
$response = Services::response(null, true);
488489
}
489490

491+
if (! $request instanceof IncomingRequest) {
492+
return;
493+
}
494+
490495
if ((ENVIRONMENT !== 'testing' && (is_cli() || $request->isSecure())) || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'test')) {
491496
// @codeCoverageIgnoreStart
492497
return;

system/Database/BaseBuilder.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ public function fromSubquery(BaseBuilder $from, string $alias): self
577577
{
578578
$table = $this->buildSubquery($from, true, $alias);
579579

580-
$this->trackAliases($table);
580+
$this->db->addTableAlias($alias);
581581
$this->QBFrom[] = $table;
582582

583583
return $this;
@@ -2705,8 +2705,7 @@ protected function objectToArray($object)
27052705
$array = [];
27062706

27072707
foreach (get_object_vars($object) as $key => $val) {
2708-
// There are some built in keys we need to ignore for this conversion
2709-
if (! is_object($val) && ! is_array($val) && $key !== '_parent_name') {
2708+
if (! is_object($val) && ! is_array($val)) {
27102709
$array[$key] = $val;
27112710
}
27122711
}
@@ -2732,13 +2731,10 @@ protected function batchObjectToArray($object)
27322731
$fields = array_keys($out);
27332732

27342733
foreach ($fields as $val) {
2735-
// There are some built in keys we need to ignore for this conversion
2736-
if ($val !== '_parent_name') {
2737-
$i = 0;
2734+
$i = 0;
27382735

2739-
foreach ($out[$val] as $data) {
2740-
$array[$i++][$val] = $data;
2741-
}
2736+
foreach ($out[$val] as $data) {
2737+
$array[$i++][$val] = $data;
27422738
}
27432739
}
27442740

@@ -2952,7 +2948,7 @@ protected function buildSubquery($builder, bool $wrapped = false, string $alias
29522948
throw new DatabaseException('The subquery cannot be the same object as the main query object.');
29532949
}
29542950

2955-
$subquery = strtr($builder->getCompiledSelect(), "\n", ' ');
2951+
$subquery = strtr($builder->getCompiledSelect(false), "\n", ' ');
29562952

29572953
if ($wrapped) {
29582954
$subquery = '(' . $subquery . ')';

system/Database/BaseConnection.php

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ public function addTableAlias(string $table)
562562
/**
563563
* Executes the query against the database.
564564
*
565-
* @return mixed
565+
* @return bool|object|resource
566566
*/
567567
abstract protected function execute(string $sql);
568568

@@ -882,7 +882,12 @@ public function table($tableName)
882882
*/
883883
public function newQuery(): BaseBuilder
884884
{
885-
return $this->table(',')->from([], true);
885+
// save table aliases
886+
$tempAliases = $this->aliasedTables;
887+
$builder = $this->table(',')->from([], true);
888+
$this->aliasedTables = $tempAliases;
889+
890+
return $builder;
886891
}
887892

888893
/**
@@ -1405,10 +1410,41 @@ public function listTables(bool $constrainByPrefix = false)
14051410

14061411
/**
14071412
* Determine if a particular table exists
1413+
*
1414+
* @param bool $cached Whether to use data cache
14081415
*/
1409-
public function tableExists(string $tableName): bool
1416+
public function tableExists(string $tableName, bool $cached = true): bool
14101417
{
1411-
return in_array($this->protectIdentifiers($tableName, true, false, false), $this->listTables(), true);
1418+
if ($cached === true) {
1419+
return in_array($this->protectIdentifiers($tableName, true, false, false), $this->listTables(), true);
1420+
}
1421+
1422+
if (false === ($sql = $this->_listTables(false, $tableName))) {
1423+
if ($this->DBDebug) {
1424+
throw new DatabaseException('This feature is not available for the database you are using.');
1425+
}
1426+
1427+
return false;
1428+
}
1429+
1430+
$tableExists = $this->query($sql)->getResultArray() !== [];
1431+
1432+
// if cache has been built already
1433+
if (! empty($this->dataCache['table_names'])) {
1434+
$key = array_search(
1435+
strtolower($tableName),
1436+
array_map('strtolower', $this->dataCache['table_names']),
1437+
true
1438+
);
1439+
1440+
// table doesn't exist but still in cache - lets reset cache, it can be rebuilt later
1441+
// OR if table does exist but is not found in cache
1442+
if (($key !== false && ! $tableExists) || ($key === false && $tableExists)) {
1443+
$this->resetDataCache();
1444+
}
1445+
}
1446+
1447+
return $tableExists;
14121448
}
14131449

14141450
/**
@@ -1575,9 +1611,11 @@ abstract public function insertID();
15751611
/**
15761612
* Generates the SQL for listing tables in a platform-dependent manner.
15771613
*
1614+
* @param string|null $tableName If $tableName is provided will return only this table if exists.
1615+
*
15781616
* @return false|string
15791617
*/
1580-
abstract protected function _listTables(bool $constrainByPrefix = false);
1618+
abstract protected function _listTables(bool $constrainByPrefix = false, ?string $tableName = null);
15811619

15821620
/**
15831621
* Generates a platform-specific query string so that the column names can be fetched.

system/Database/Forge.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public function createTable(string $table, bool $ifNotExists = false, array $att
498498
}
499499

500500
// If table exists lets stop here
501-
if ($ifNotExists === true && $this->db->tableExists($table)) {
501+
if ($ifNotExists === true && $this->db->tableExists($table, false)) {
502502
$this->reset();
503503

504504
return true;
@@ -776,7 +776,7 @@ public function modifyColumn(string $table, $field): bool
776776
}
777777

778778
/**
779-
* @param mixed $fields
779+
* @param array|string $fields
780780
*
781781
* @return false|string|string[]
782782
*/

system/Database/MySQLi/Connection.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public function getVersion(): string
277277
/**
278278
* Executes the query against the database.
279279
*
280-
* @return mixed
280+
* @return bool|object
281281
*/
282282
protected function execute(string $sql)
283283
{
@@ -368,11 +368,17 @@ public function escapeLikeStringDirect($str)
368368
/**
369369
* Generates the SQL for listing tables in a platform-dependent manner.
370370
* Uses escapeLikeStringDirect().
371+
*
372+
* @param string|null $tableName If $tableName is provided will return only this table if exists.
371373
*/
372-
protected function _listTables(bool $prefixLimit = false): string
374+
protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string
373375
{
374376
$sql = 'SHOW TABLES FROM ' . $this->escapeIdentifiers($this->database);
375377

378+
if ($tableName !== null) {
379+
return $sql . ' LIKE ' . $this->escape($tableName);
380+
}
381+
376382
if ($prefixLimit !== false && $this->DBPrefix !== '') {
377383
return $sql . " LIKE '" . $this->escapeLikeStringDirect($this->DBPrefix) . "%'";
378384
}

0 commit comments

Comments
 (0)