Skip to content

Commit 10c23e9

Browse files
committed
Release
1 parent 7c663e1 commit 10c23e9

File tree

93 files changed

+767
-110
lines changed

Some content is hidden

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

93 files changed

+767
-110
lines changed

composer.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
22
"name": "codeigniter4/framework",
3-
"type": "project",
43
"description": "The CodeIgniter framework v4",
5-
"homepage": "https://codeigniter.com",
64
"license": "MIT",
5+
"type": "project",
6+
"homepage": "https://codeigniter.com",
7+
"support": {
8+
"forum": "https://forum.codeigniter.com/",
9+
"source": "https://github.com/codeigniter4/CodeIgniter4",
10+
"slack": "https://codeigniterchat.slack.com"
11+
},
712
"require": {
813
"php": "^7.4 || ^8.0",
914
"ext-intl": "*",
@@ -13,39 +18,34 @@
1318
"psr/log": "^1.1"
1419
},
1520
"require-dev": {
16-
"kint-php/kint": "^5.0.4",
1721
"codeigniter/coding-standard": "^1.5",
1822
"fakerphp/faker": "^1.9",
1923
"friendsofphp/php-cs-fixer": "3.13.0",
24+
"kint-php/kint": "^5.0.4",
2025
"mikey179/vfsstream": "^1.6",
2126
"nexusphp/cs-config": "^3.6",
2227
"phpunit/phpunit": "^9.1",
2328
"predis/predis": "^1.1 || ^2.0"
2429
},
2530
"suggest": {
2631
"ext-curl": "If you use CURLRequest class",
27-
"ext-imagick": "If you use Image class ImageMagickHandler",
28-
"ext-gd": "If you use Image class GDHandler",
32+
"ext-dom": "If you use TestResponse",
2933
"ext-exif": "If you run Image class tests",
30-
"ext-simplexml": "If you format XML",
34+
"ext-fileinfo": "Improves mime type detection for files",
35+
"ext-gd": "If you use Image class GDHandler",
36+
"ext-imagick": "If you use Image class ImageMagickHandler",
37+
"ext-libxml": "If you use TestResponse",
38+
"ext-memcache": "If you use Cache class MemcachedHandler with Memcache",
39+
"ext-memcached": "If you use Cache class MemcachedHandler with Memcached",
3140
"ext-mysqli": "If you use MySQL",
3241
"ext-oci8": "If you use Oracle Database",
3342
"ext-pgsql": "If you use PostgreSQL",
34-
"ext-sqlsrv": "If you use SQL Server",
35-
"ext-sqlite3": "If you use SQLite3",
36-
"ext-memcache": "If you use Cache class MemcachedHandler with Memcache",
37-
"ext-memcached": "If you use Cache class MemcachedHandler with Memcached",
43+
"ext-readline": "Improves CLI::input() usability",
3844
"ext-redis": "If you use Cache class RedisHandler",
39-
"ext-dom": "If you use TestResponse",
40-
"ext-libxml": "If you use TestResponse",
41-
"ext-xdebug": "If you use CIUnitTestCase::assertHeaderEmitted()",
42-
"ext-fileinfo": "Improves mime type detection for files",
43-
"ext-readline": "Improves CLI::input() usability"
44-
},
45-
"config": {
46-
"optimize-autoloader": true,
47-
"preferred-install": "dist",
48-
"sort-packages": true
45+
"ext-simplexml": "If you format XML",
46+
"ext-sqlite3": "If you use SQLite3",
47+
"ext-sqlsrv": "If you use SQL Server",
48+
"ext-xdebug": "If you use CIUnitTestCase::assertHeaderEmitted()"
4949
},
5050
"autoload": {
5151
"psr-4": {
@@ -55,12 +55,12 @@
5555
"**/Database/Migrations/**"
5656
]
5757
},
58+
"config": {
59+
"optimize-autoloader": true,
60+
"preferred-install": "dist",
61+
"sort-packages": true
62+
},
5863
"scripts": {
5964
"test": "phpunit"
60-
},
61-
"support": {
62-
"forum": "https://forum.codeigniter.com/",
63-
"source": "https://github.com/codeigniter4/CodeIgniter4",
64-
"slack": "https://codeigniterchat.slack.com"
6565
}
6666
}

system/BaseModel.php

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ public function __construct(?ValidationInterface $validation = null)
338338
/**
339339
* Initializes the instance with any additional steps.
340340
* Optionally implemented by child classes.
341+
*
342+
* @return void
341343
*/
342344
protected function initialize()
343345
{
@@ -458,6 +460,8 @@ abstract protected function doPurgeDeleted();
458460
* Works with the find* methods to return only the rows that
459461
* have been deleted.
460462
* This method works only with dbCalls.
463+
*
464+
* @return void
461465
*/
462466
abstract protected function doOnlyDeleted();
463467

@@ -524,6 +528,8 @@ abstract public function countAllResults(bool $reset = true, bool $test = false)
524528
* @param int $size Size
525529
* @param Closure $userFunc Callback Function
526530
*
531+
* @return void
532+
*
527533
* @throws DataException
528534
*/
529535
abstract public function chunk(int $size, Closure $userFunc);
@@ -754,7 +760,7 @@ public function insert($data = null, bool $returnID = true)
754760

755761
// Must be called first, so we don't
756762
// strip out created_at values.
757-
$data = $this->doProtectFields($data);
763+
$data = $this->doProtectFieldsForInsert($data);
758764

759765
// doProtectFields() can further remove elements from
760766
// $data so we need to check for empty dataset again
@@ -847,7 +853,7 @@ public function insertBatch(?array $set = null, ?bool $escape = null, int $batch
847853

848854
// Must be called first so we don't
849855
// strip out created_at values.
850-
$row = $this->doProtectFields($row);
856+
$row = $this->doProtectFieldsForInsert($row);
851857

852858
// Set created_at and updated_at with same time
853859
$date = $this->setDate();
@@ -973,7 +979,9 @@ public function updateBatch(?array $set = null, ?string $index = null, int $batc
973979
// properties representing the collection elements, we need to grab
974980
// them as an array.
975981
if (is_object($row) && ! $row instanceof stdClass) {
976-
$row = $this->objectToArray($row, true, true);
982+
// For updates the index field is needed even if it is not changed.
983+
// So set $onlyChanged to false.
984+
$row = $this->objectToArray($row, false, true);
977985
}
978986

979987
// If it's still a stdClass, go ahead and convert to
@@ -991,6 +999,13 @@ public function updateBatch(?array $set = null, ?string $index = null, int $batc
991999
// Save updateIndex for later
9921000
$updateIndex = $row[$index] ?? null;
9931001

1002+
if ($updateIndex === null) {
1003+
throw new InvalidArgumentException(
1004+
'The index ("' . $index . '") for updateBatch() is missing in the data: '
1005+
. json_encode($row)
1006+
);
1007+
}
1008+
9941009
// Must be called first so we don't
9951010
// strip out updated_at values.
9961011
$row = $this->doProtectFields($row);
@@ -1222,10 +1237,10 @@ public function protect(bool $protect = true)
12221237
}
12231238

12241239
/**
1225-
* Ensures that only the fields that are allowed to be updated
1226-
* are in the data array.
1240+
* Ensures that only the fields that are allowed to be updated are
1241+
* in the data array.
12271242
*
1228-
* Used by insert() and update() to protect against mass assignment
1243+
* Used by update() and updateBatch() to protect against mass assignment
12291244
* vulnerabilities.
12301245
*
12311246
* @param array $data Data
@@ -1251,6 +1266,22 @@ protected function doProtectFields(array $data): array
12511266
return $data;
12521267
}
12531268

1269+
/**
1270+
* Ensures that only the fields that are allowed to be inserted are in
1271+
* the data array.
1272+
*
1273+
* Used by insert() and insertBatch() to protect against mass assignment
1274+
* vulnerabilities.
1275+
*
1276+
* @param array $data Data
1277+
*
1278+
* @throws DataException
1279+
*/
1280+
protected function doProtectFieldsForInsert(array $data): array
1281+
{
1282+
return $this->doProtectFields($data);
1283+
}
1284+
12541285
/**
12551286
* Sets the date or current date if null value is passed.
12561287
*

system/CLI/BaseCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ protected function call(string $command, array $params = [])
117117

118118
/**
119119
* A simple method to display an error with line/file, in child commands.
120+
*
121+
* @return void
120122
*/
121123
protected function showError(Throwable $e)
122124
{
@@ -129,6 +131,8 @@ protected function showError(Throwable $e)
129131

130132
/**
131133
* Show Help includes (Usage, Arguments, Description, Options).
134+
*
135+
* @return void
132136
*/
133137
public function showHelp()
134138
{

system/CLI/CLI.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ class CLI
142142

143143
/**
144144
* Static "constructor".
145+
*
146+
* @return void
145147
*/
146148
public static function init()
147149
{
@@ -429,6 +431,8 @@ protected static function validate(string $field, string $value, $rules): bool
429431
/**
430432
* Outputs a string to the CLI without any surrounding newlines.
431433
* Useful for showing repeating elements on a single line.
434+
*
435+
* @return void
432436
*/
433437
public static function print(string $text = '', ?string $foreground = null, ?string $background = null)
434438
{
@@ -443,6 +447,8 @@ public static function print(string $text = '', ?string $foreground = null, ?str
443447

444448
/**
445449
* Outputs a string to the cli on it's own line.
450+
*
451+
* @return void
446452
*/
447453
public static function write(string $text = '', ?string $foreground = null, ?string $background = null)
448454
{
@@ -460,6 +466,8 @@ public static function write(string $text = '', ?string $foreground = null, ?str
460466

461467
/**
462468
* Outputs an error to the CLI using STDERR instead of STDOUT
469+
*
470+
* @return void
463471
*/
464472
public static function error(string $text, string $foreground = 'light_red', ?string $background = null)
465473
{
@@ -481,6 +489,8 @@ public static function error(string $text, string $foreground = 'light_red', ?st
481489
* Beeps a certain number of times.
482490
*
483491
* @param int $num The number of times to beep
492+
*
493+
* @return void
484494
*/
485495
public static function beep(int $num = 1)
486496
{
@@ -493,6 +503,8 @@ public static function beep(int $num = 1)
493503
*
494504
* @param int $seconds Number of seconds
495505
* @param bool $countdown Show a countdown or not
506+
*
507+
* @return void
496508
*/
497509
public static function wait(int $seconds, bool $countdown = false)
498510
{
@@ -529,6 +541,8 @@ public static function isWindows(): bool
529541

530542
/**
531543
* Enter a number of empty lines
544+
*
545+
* @return void
532546
*/
533547
public static function newLine(int $num = 1)
534548
{
@@ -542,6 +556,8 @@ public static function newLine(int $num = 1)
542556
* Clears the screen of output
543557
*
544558
* @codeCoverageIgnore
559+
*
560+
* @return void
545561
*/
546562
public static function clearScreen()
547563
{
@@ -735,6 +751,8 @@ public static function getHeight(int $default = 32): int
735751
* Populates the CLI's dimensions.
736752
*
737753
* @codeCoverageIgnore
754+
*
755+
* @return void
738756
*/
739757
public static function generateDimensions()
740758
{
@@ -778,6 +796,8 @@ public static function generateDimensions()
778796
* to update it. Set $thisStep = false to erase the progress bar.
779797
*
780798
* @param bool|int $thisStep
799+
*
800+
* @return void
781801
*/
782802
public static function showProgress($thisStep = 1, int $totalSteps = 10)
783803
{
@@ -859,6 +879,8 @@ public static function wrap(?string $string = null, int $max = 0, int $padLeft =
859879
/**
860880
* Parses the command line it was called from and collects all
861881
* options and valid segments.
882+
*
883+
* @return void
862884
*/
863885
protected static function parseCommandLine()
864886
{
@@ -998,6 +1020,8 @@ public static function getOptionString(bool $useLongOpts = false, bool $trim = f
9981020
*
9991021
* @param array $tbody List of rows
10001022
* @param array $thead List of columns
1023+
*
1024+
* @return void
10011025
*/
10021026
public static function table(array $tbody, array $thead = [])
10031027
{
@@ -1096,6 +1120,8 @@ public static function table(array $tbody, array $thead = [])
10961120
* solution down the road.
10971121
*
10981122
* @param resource $handle
1123+
*
1124+
* @return void
10991125
*/
11001126
protected static function fwrite($handle, string $string)
11011127
{

system/CLI/Commands.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public function getCommands()
7878
/**
7979
* Discovers all commands in the framework and within user code,
8080
* and collects instances of them to work with.
81+
*
82+
* @return void
8183
*/
8284
public function discoverCommands()
8385
{

system/CLI/Console.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function run()
3939

4040
/**
4141
* Displays basic information about the Console.
42+
*
43+
* @return void
4244
*/
4345
public function showHeader(bool $suppress = false)
4446
{

system/Cache/CacheInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ interface CacheInterface
1818
{
1919
/**
2020
* Takes care of any handler-specific setup that must be done.
21+
*
22+
* @return void
2123
*/
2224
public function initialize();
2325

system/CodeIgniter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CodeIgniter
4848
/**
4949
* The current version of CodeIgniter Framework
5050
*/
51-
public const CI_VERSION = '4.3.7';
51+
public const CI_VERSION = '4.3.8';
5252

5353
/**
5454
* App startup time.

system/Common.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,8 @@ function esc($data, string $context = 'html', ?string $encoding = null)
470470
*
471471
* @see https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security
472472
*
473-
* @param int $duration How long should the SSL header be set for? (in seconds)
474-
* Defaults to 1 year.
475-
* @param RequestInterface $request
476-
* @param ResponseInterface $response
473+
* @param int $duration How long should the SSL header be set for? (in seconds)
474+
* Defaults to 1 year.
477475
*
478476
* @throws HTTPException
479477
*/

system/Config/BaseConfig.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ protected function getEnvValue(string $property, string $prefix, string $shortPr
169169
* Provides external libraries a simple way to register one or more
170170
* options into a config file.
171171
*
172+
* @return void
173+
*
172174
* @throws ReflectionException
173175
*/
174176
protected function registerProperties()

0 commit comments

Comments
 (0)