Skip to content

Commit 1e6cde3

Browse files
authored
Merge branch 'codeigniter4:develop' into patch-2
2 parents 28d9a43 + 747108f commit 1e6cde3

File tree

8 files changed

+44
-124
lines changed

8 files changed

+44
-124
lines changed

phpstan-baseline.php

Lines changed: 12 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,41 +1791,6 @@
17911791
'count' => 1,
17921792
'path' => __DIR__ . '/system/Database/BaseBuilder.php',
17931793
];
1794-
$ignoreErrors[] = [
1795-
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_deleteBatch\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
1796-
'count' => 1,
1797-
'path' => __DIR__ . '/system/Database/BaseBuilder.php',
1798-
];
1799-
$ignoreErrors[] = [
1800-
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_insert\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#',
1801-
'count' => 1,
1802-
'path' => __DIR__ . '/system/Database/BaseBuilder.php',
1803-
];
1804-
$ignoreErrors[] = [
1805-
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_insert\\(\\) has parameter \\$unescapedKeys with no value type specified in iterable type array\\.$#',
1806-
'count' => 1,
1807-
'path' => __DIR__ . '/system/Database/BaseBuilder.php',
1808-
];
1809-
$ignoreErrors[] = [
1810-
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_like\\(\\) has parameter \\$field with no value type specified in iterable type array\\.$#',
1811-
'count' => 1,
1812-
'path' => __DIR__ . '/system/Database/BaseBuilder.php',
1813-
];
1814-
$ignoreErrors[] = [
1815-
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_replace\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#',
1816-
'count' => 1,
1817-
'path' => __DIR__ . '/system/Database/BaseBuilder.php',
1818-
];
1819-
$ignoreErrors[] = [
1820-
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_replace\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
1821-
'count' => 1,
1822-
'path' => __DIR__ . '/system/Database/BaseBuilder.php',
1823-
];
1824-
$ignoreErrors[] = [
1825-
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_update\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
1826-
'count' => 1,
1827-
'path' => __DIR__ . '/system/Database/BaseBuilder.php',
1828-
];
18291794
$ignoreErrors[] = [
18301795
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_whereIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#',
18311796
'count' => 1,
@@ -2206,6 +2171,11 @@
22062171
'count' => 1,
22072172
'path' => __DIR__ . '/system/Database/BaseBuilder.php',
22082173
];
2174+
$ignoreErrors[] = [
2175+
'message' => '#^Parameter \\#3 \\.\\.\\.\\$arrays of function array_map expects array, int\\|string given\\.$#',
2176+
'count' => 1,
2177+
'path' => __DIR__ . '/system/Database/BaseBuilder.php',
2178+
];
22092179
$ignoreErrors[] = [
22102180
'message' => '#^Property CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:\\$QBFrom type has no value type specified in iterable type array\\.$#',
22112181
'count' => 1,
@@ -3122,37 +3092,22 @@
31223092
'path' => __DIR__ . '/system/Database/OCI8/Builder.php',
31233093
];
31243094
$ignoreErrors[] = [
3125-
'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:_deleteBatch\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
3126-
'count' => 1,
3127-
'path' => __DIR__ . '/system/Database/OCI8/Builder.php',
3128-
];
3129-
$ignoreErrors[] = [
3130-
'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:_replace\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#',
3131-
'count' => 1,
3132-
'path' => __DIR__ . '/system/Database/OCI8/Builder.php',
3133-
];
3134-
$ignoreErrors[] = [
3135-
'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:_replace\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
3136-
'count' => 1,
3137-
'path' => __DIR__ . '/system/Database/OCI8/Builder.php',
3138-
];
3139-
$ignoreErrors[] = [
3140-
'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:_update\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
3095+
'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:fieldsFromQuery\\(\\) return type has no value type specified in iterable type array\\.$#',
31413096
'count' => 1,
31423097
'path' => __DIR__ . '/system/Database/OCI8/Builder.php',
31433098
];
31443099
$ignoreErrors[] = [
3145-
'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:fieldsFromQuery\\(\\) return type has no value type specified in iterable type array\\.$#',
3100+
'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:resetSelect\\(\\) has no return type specified\\.$#',
31463101
'count' => 1,
31473102
'path' => __DIR__ . '/system/Database/OCI8/Builder.php',
31483103
];
31493104
$ignoreErrors[] = [
3150-
'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:resetSelect\\(\\) has no return type specified\\.$#',
3105+
'message' => '#^PHPDoc type CodeIgniter\\\\Database\\\\OCI8\\\\Connection of property CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:\\$db is not the same as PHPDoc type CodeIgniter\\\\Database\\\\BaseConnection of overridden property CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:\\$db\\.$#',
31513106
'count' => 1,
31523107
'path' => __DIR__ . '/system/Database/OCI8/Builder.php',
31533108
];
31543109
$ignoreErrors[] = [
3155-
'message' => '#^PHPDoc type CodeIgniter\\\\Database\\\\OCI8\\\\Connection of property CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:\\$db is not the same as PHPDoc type CodeIgniter\\\\Database\\\\BaseConnection of overridden property CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:\\$db\\.$#',
3110+
'message' => '#^Parameter \\#3 \\.\\.\\.\\$arrays of function array_map expects array, int\\|string given\\.$#',
31563111
'count' => 1,
31573112
'path' => __DIR__ . '/system/Database/OCI8/Builder.php',
31583113
];
@@ -3317,27 +3272,12 @@
33173272
'path' => __DIR__ . '/system/Database/Postgre/Builder.php',
33183273
];
33193274
$ignoreErrors[] = [
3320-
'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Builder\\:\\:_deleteBatch\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
3321-
'count' => 1,
3322-
'path' => __DIR__ . '/system/Database/Postgre/Builder.php',
3323-
];
3324-
$ignoreErrors[] = [
3325-
'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Builder\\:\\:_insert\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#',
3326-
'count' => 1,
3327-
'path' => __DIR__ . '/system/Database/Postgre/Builder.php',
3328-
];
3329-
$ignoreErrors[] = [
3330-
'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Builder\\:\\:_insert\\(\\) has parameter \\$unescapedKeys with no value type specified in iterable type array\\.$#',
3331-
'count' => 1,
3332-
'path' => __DIR__ . '/system/Database/Postgre/Builder.php',
3333-
];
3334-
$ignoreErrors[] = [
3335-
'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Builder\\:\\:_update\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
3275+
'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Builder\\:\\:replace\\(\\) has parameter \\$set with no value type specified in iterable type array\\.$#',
33363276
'count' => 1,
33373277
'path' => __DIR__ . '/system/Database/Postgre/Builder.php',
33383278
];
33393279
$ignoreErrors[] = [
3340-
'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Builder\\:\\:replace\\(\\) has parameter \\$set with no value type specified in iterable type array\\.$#',
3280+
'message' => '#^Parameter \\#3 \\.\\.\\.\\$arrays of function array_map expects array, int\\|string given\\.$#',
33413281
'count' => 1,
33423282
'path' => __DIR__ . '/system/Database/Postgre/Builder.php',
33433283
];
@@ -3676,31 +3616,6 @@
36763616
'count' => 9,
36773617
'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php',
36783618
];
3679-
$ignoreErrors[] = [
3680-
'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Builder\\:\\:_insert\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#',
3681-
'count' => 1,
3682-
'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php',
3683-
];
3684-
$ignoreErrors[] = [
3685-
'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Builder\\:\\:_insert\\(\\) has parameter \\$unescapedKeys with no value type specified in iterable type array\\.$#',
3686-
'count' => 1,
3687-
'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php',
3688-
];
3689-
$ignoreErrors[] = [
3690-
'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Builder\\:\\:_replace\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#',
3691-
'count' => 1,
3692-
'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php',
3693-
];
3694-
$ignoreErrors[] = [
3695-
'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Builder\\:\\:_replace\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
3696-
'count' => 1,
3697-
'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php',
3698-
];
3699-
$ignoreErrors[] = [
3700-
'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Builder\\:\\:_update\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
3701-
'count' => 1,
3702-
'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php',
3703-
];
37043619
$ignoreErrors[] = [
37053620
'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Builder\\:\\:fieldsFromQuery\\(\\) return type has no value type specified in iterable type array\\.$#',
37063621
'count' => 1,
@@ -3907,17 +3822,7 @@
39073822
'path' => __DIR__ . '/system/Database/SQLite3/Builder.php',
39083823
];
39093824
$ignoreErrors[] = [
3910-
'message' => '#^Method CodeIgniter\\\\Database\\\\SQLite3\\\\Builder\\:\\:_deleteBatch\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
3911-
'count' => 1,
3912-
'path' => __DIR__ . '/system/Database/SQLite3/Builder.php',
3913-
];
3914-
$ignoreErrors[] = [
3915-
'message' => '#^Method CodeIgniter\\\\Database\\\\SQLite3\\\\Builder\\:\\:_replace\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#',
3916-
'count' => 1,
3917-
'path' => __DIR__ . '/system/Database/SQLite3/Builder.php',
3918-
];
3919-
$ignoreErrors[] = [
3920-
'message' => '#^Method CodeIgniter\\\\Database\\\\SQLite3\\\\Builder\\:\\:_replace\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#',
3825+
'message' => '#^Parameter \\#3 \\.\\.\\.\\$arrays of function array_map expects array, int\\|string given\\.$#',
39213826
'count' => 1,
39223827
'path' => __DIR__ . '/system/Database/SQLite3/Builder.php',
39233828
];

system/Database/BaseBuilder.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ public function orNotHavingLike($field, string $match = '', string $side = 'both
10901090
* @used-by notHavingLike()
10911091
* @used-by orNotHavingLike()
10921092
*
1093-
* @param array|RawSql|string $field
1093+
* @param array<string, string>|RawSql|string $field
10941094
*
10951095
* @return $this
10961096
*/
@@ -2376,7 +2376,9 @@ protected function validateInsert(): bool
23762376
/**
23772377
* Generates a platform-specific insert string from the supplied data
23782378
*
2379-
* @param string $table Protected table name
2379+
* @param string $table Protected table name
2380+
* @param list<string> $keys Keys of QBSet
2381+
* @param list<int|string> $unescapedKeys Values of QBSet
23802382
*/
23812383
protected function _insert(string $table, array $keys, array $unescapedKeys): string
23822384
{
@@ -2416,7 +2418,9 @@ public function replace(?array $set = null)
24162418
/**
24172419
* Generates a platform-specific replace string from the supplied data
24182420
*
2419-
* @param string $table Protected table name
2421+
* @param string $table Protected table name
2422+
* @param list<string> $keys Keys of QBSet
2423+
* @param list<int|string> $values Values of QBSet
24202424
*/
24212425
protected function _replace(string $table, array $keys, array $values): string
24222426
{
@@ -2512,7 +2516,8 @@ public function update($set = null, $where = null, ?int $limit = null): bool
25122516
/**
25132517
* Generates a platform-specific update string from the supplied data
25142518
*
2515-
* @param string $table Protected table name
2519+
* @param string $table Protected table name
2520+
* @param array<string, string> $values QBSet
25162521
*/
25172522
protected function _update(string $table, array $values): string
25182523
{
@@ -2863,9 +2868,9 @@ public function deleteBatch($set = null, $constraints = null, int $batchSize = 1
28632868
*
28642869
* @used-by batchExecute()
28652870
*
2866-
* @param string $table Protected table name
2867-
* @param list<string> $keys QBKeys
2868-
* @paramst<string|int>> $values QBSet
2871+
* @param string $table Protected table name
2872+
* @param list<string> $keys QBKeys
2873+
* @param list<int|string> $values QBSet
28692874
*/
28702875
protected function _deleteBatch(string $table, array $keys, array $values): string
28712876
{

system/HTTP/ResponseTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ private function dispatchCookies(): void
670670

671671
foreach ($this->cookieStore->display() as $cookie) {
672672
if ($cookie->isSecure() && ! $request->isSecure()) {
673-
throw SecurityException::forDisallowedAction();
673+
throw SecurityException::forInsecureCookie();
674674
}
675675

676676
$name = $cookie->getPrefixedName();

system/Language/en/Security.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// Security language settings
1515
return [
1616
'disallowedAction' => 'The action you requested is not allowed.',
17+
'insecureCookie' => 'Attempted to send a secure cookie over a non-secure connection.',
1718

1819
// @deprecated
1920
'invalidSameSite' => 'The SameSite value must be None, Lax, Strict, or a blank string. Given: "{0}"',

system/Security/Exceptions/SecurityException.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class SecurityException extends FrameworkException implements HTTPExceptionInter
2020
{
2121
/**
2222
* Throws when some specific action is not allowed.
23+
* This is used for CSRF protection.
2324
*
2425
* @return static
2526
*/
@@ -28,6 +29,15 @@ public static function forDisallowedAction()
2829
return new static(lang('Security.disallowedAction'), 403);
2930
}
3031

32+
/**
33+
* Throws if a secure cookie is dispatched when the current connection is not
34+
* secure.
35+
*/
36+
public static function forInsecureCookie(): static
37+
{
38+
return new static(lang('Security.insecureCookie'));
39+
}
40+
3141
/**
3242
* Throws when the source string contains invalid UTF-8 characters.
3343
*

tests/system/HTTP/ResponseSendTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,11 @@ public function testRedirectResponseCookies(): void
162162

163163
/**
164164
* Make sure secure cookies are not sent with HTTP request
165-
*
166-
* @ runInSeparateProcess
167-
* @ preserveGlobalState disabled
168165
*/
169166
public function testDoNotSendUnSecureCookie(): void
170167
{
171168
$this->expectException(SecurityException::class);
172-
$this->expectExceptionMessage('The action you requested is not allowed');
169+
$this->expectExceptionMessage('Attempted to send a secure cookie over a non-secure connection.');
173170

174171
$request = $this->createMock(IncomingRequest::class);
175172
$request->method('isSecure')->willReturn(false);

user_guide_src/source/changelogs/v4.5.2.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ BREAKING
1818
Message Changes
1919
***************
2020

21+
- Added ``Security.insecureCookie`` message.
22+
2123
*******
2224
Changes
2325
*******

user_guide_src/source/database/examples.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
##################################
2-
Database Quick Start: Example Code
3-
##################################
1+
###########################
2+
Quick Start: Usage Examples
3+
###########################
44

55
The following page contains example code showing how the database class
66
is used. For complete details please read the individual pages
@@ -24,7 +24,7 @@ your :doc:`configuration <configuration>` settings:
2424
Once loaded the class is ready to be used as described below.
2525

2626
.. note:: If all your pages require database access you can connect
27-
automatically. See the :doc:`connecting <connecting>` page for details.
27+
automatically. See the :doc:`Connecting to a Database <connecting>` page for details.
2828

2929
Standard Query With Multiple Results (Object Version)
3030
=====================================================
@@ -66,7 +66,7 @@ Standard Insert
6666
Query Builder Query
6767
===================
6868

69-
The :doc:`Query Builder Pattern <query_builder>` gives you a simplified
69+
The :doc:`Query Builder <query_builder>` gives you a simplified
7070
means of retrieving data:
7171

7272
.. literalinclude:: examples/007.php

0 commit comments

Comments
 (0)