Skip to content

Commit b2abc93

Browse files
Merge branch 'develop' into fix-sync-request-after-get-change
2 parents 61bf7b9 + fba4362 commit b2abc93

11 files changed

Lines changed: 70 additions & 19 deletions

File tree

‎.github/carson.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ settings:
5656
Closing this issue: the description still does not follow the bug report template after {{days_until_close}} days.
5757
5858
Please open a new issue using the [bug report form](https://github.com/codeigniter4/CodeIgniter4/issues/new?assignees=&labels=bug&projects=&template=bug_report.yml&title=Bug%3A+). For feature requests or support questions, please use the [forums](https://forum.codeigniter.com/forum-30.html).
59+
- label: waiting for info
60+
days_until_close: 14
61+
unlabel_on_response: true
62+
close_message: |-
63+
Closing this {{type}}: there has been no response for {{days_until_close}} days after more information was requested.
64+
65+
If you can provide the requested details, leave a comment and a maintainer can reopen it.
5966
pr-title-linter:
6067
name: 'Carson / pr-title-linter'
6168
rules:

‎.github/workflows/run-carson.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414
- opened
1515
- edited
1616
- labeled
17+
issue_comment:
18+
types:
19+
- created
1720
push:
1821
branches:
1922
- develop
@@ -28,7 +31,7 @@ jobs:
2831
runs-on: ubuntu-24.04
2932
steps:
3033
- name: Run Carson
31-
uses: NexusPHP/carson@e4b2fde33f32c47455df218cf1765702c15c3b8b # v1.6.0
34+
uses: NexusPHP/carson@cb35604ab330c2e44dba673fcef712c78e75f858 # v1.7.0
3235
with:
3336
app_id: ${{ secrets.CARSON_APP_ID }}
3437
private_key: ${{ secrets.CARSON_PRIVATE_KEY }}

‎system/Database/Postgre/Connection.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,13 @@ public function getVersion(): string
207207
protected function execute(string $sql)
208208
{
209209
try {
210-
return pg_query($this->connID, $sql);
210+
$result = pg_query($this->connID, $sql);
211+
212+
if ($result === false && $this->DBDebug) {
213+
throw new DatabaseException(pg_last_error($this->connID));
214+
}
215+
216+
return $result;
211217
} catch (ErrorException $e) {
212218
$trace = array_slice($e->getTrace(), 2); // remove the call to error handler
213219

‎system/Database/ResultInterface.php‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,22 @@ interface ResultInterface
2626
* individual data rows, which can be either an 'array', an
2727
* 'object', or a custom class name.
2828
*
29-
* @param string $type The row type. Either 'array', 'object', or a class name to use
29+
* @template T of object
30+
*
31+
* @param 'array'|'object'|class-string<T> $type The row type. Either 'array', 'object', or a class name to use
3032
*
31-
* @return ($type is 'array' ? list<array<string, mixed>> : ($type is 'object' ? list<stdClass> : list<object>))
33+
* @return ($type is 'array' ? list<array<string, mixed>> : ($type is 'object' ? list<stdClass> : list<T>))
3234
*/
3335
public function getResult(string $type = 'object'): array;
3436

3537
/**
3638
* Returns the results as an array of custom objects.
3739
*
38-
* @param string $className The name of the class to use.
40+
* @template T of object
41+
*
42+
* @param class-string<T> $className The name of the class to use.
3943
*
40-
* @return list<object>
44+
* @return list<T>
4145
*/
4246
public function getCustomResultObject(string $className);
4347

@@ -102,7 +106,7 @@ public function getRowArray(int $n = 0);
102106
*
103107
* If row doesn't exist, returns null.
104108
*
105-
* @return object|stdClass|null
109+
* @return stdClass|null
106110
*/
107111
public function getRowObject(int $n = 0);
108112

‎system/HTTP/CLIRequest.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public function isCLI(): bool
236236
* @param int|null $filter A filter name to apply.
237237
* @param array<string, mixed>|int|null $flags
238238
*
239-
* @return array{}|null
239+
* @return ($index is string ? null : array{})
240240
*/
241241
public function getGet($index = null, $filter = null, $flags = null)
242242
{
@@ -250,7 +250,7 @@ public function getGet($index = null, $filter = null, $flags = null)
250250
* @param int|null $filter A filter name to apply
251251
* @param array<string, mixed>|int|null $flags
252252
*
253-
* @return array{}|null
253+
* @return ($index is string ? null : array{})
254254
*/
255255
public function getPost($index = null, $filter = null, $flags = null)
256256
{
@@ -264,7 +264,7 @@ public function getPost($index = null, $filter = null, $flags = null)
264264
* @param int|null $filter A filter name to apply
265265
* @param array<string, mixed>|int|null $flags
266266
*
267-
* @return array{}|null
267+
* @return ($index is string ? null : array{})
268268
*/
269269
public function getPostGet($index = null, $filter = null, $flags = null)
270270
{
@@ -278,7 +278,7 @@ public function getPostGet($index = null, $filter = null, $flags = null)
278278
* @param int|null $filter A filter name to apply
279279
* @param array<string, mixed>|int|null $flags
280280
*
281-
* @return array{}|null
281+
* @return ($index is string ? null : array{})
282282
*/
283283
public function getGetPost($index = null, $filter = null, $flags = null)
284284
{
@@ -292,7 +292,7 @@ public function getGetPost($index = null, $filter = null, $flags = null)
292292
* @param int|null $filter A filter name to be applied
293293
* @param mixed $flags
294294
*
295-
* @return array{}|null
295+
* @return ($index is string ? null : array{})
296296
*/
297297
public function getCookie($index = null, $filter = null, $flags = null)
298298
{
@@ -302,7 +302,7 @@ public function getCookie($index = null, $filter = null, $flags = null)
302302
/**
303303
* @param list<string>|string|null $index
304304
*
305-
* @return array{}|null
305+
* @return ($index is string ? null : array{})
306306
*/
307307
private function returnNullOrEmptyArray($index)
308308
{

‎system/HTTP/IncomingRequest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public function getVar($index = null, $filter = null, $flags = null)
409409
*
410410
* @see http://php.net/manual/en/function.json-decode.php
411411
*
412-
* @return array<array-key, mixed>|bool|float|int|stdClass|null
412+
* @return ($assoc is true ? array<array-key, mixed>|bool|float|int|string|null : array<array-key, mixed>|bool|float|int|stdClass|string|null)
413413
*
414414
* @throws HTTPException When the body is invalid as JSON.
415415
*/
@@ -436,7 +436,7 @@ public function getJSON(bool $assoc = false, int $depth = 512, int $options = 0)
436436
* @param int|null $filter Filter Constant
437437
* @param array<string, mixed>|int|null $flags Option
438438
*
439-
* @return array<array-key, mixed>|bool|float|int|stdClass|string|null
439+
* @return ($assoc is true ? array<array-key, mixed>|bool|float|int|string|null : array<array-key, mixed>|bool|float|int|stdClass|string|null)
440440
*/
441441
public function getJsonVar($index = null, bool $assoc = false, ?int $filter = null, $flags = null)
442442
{

‎system/Helpers/url_helper.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ function base_url($relativePath = '', ?string $scheme = null): string
6868
* @param bool $returnObject True to return an object instead of a string
6969
* @param IncomingRequest|null $request A request to use when retrieving the path
7070
*
71-
* @return string|URI When returning string, the query and fragment parts are removed.
72-
* When returning URI, the query and fragment parts are preserved.
71+
* @return ($returnObject is true ? URI : string) When returning string, the query and fragment parts are removed.
72+
* When returning URI, the query and fragment parts are preserved.
7373
*/
7474
function current_url(bool $returnObject = false, ?IncomingRequest $request = null): string|URI
7575
{
@@ -87,6 +87,8 @@ function current_url(bool $returnObject = false, ?IncomingRequest $request = nul
8787
* we first check in a saved session variable, if it exists, and use that.
8888
* If that's not available, however, we'll use a sanitized url from $_SERVER['HTTP_REFERER']
8989
* which can be set by the user so is untrusted and not set by certain browsers/servers.
90+
*
91+
* @return ($returnObject is true ? URI : string)
9092
*/
9193
function previous_url(bool $returnObject = false): string|URI
9294
{

‎system/Validation/CreditCardRules.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ public function valid_cc_number(?string $ccNumber, string $type): bool
199199
// Remove any spaces and dashes
200200
$ccNumber = str_replace([' ', '-'], '', $ccNumber);
201201

202-
// Non-numeric values cannot be a number...duh
203-
if (! is_numeric($ccNumber)) {
202+
if (! ctype_digit($ccNumber)) {
204203
return false;
205204
}
206205

‎tests/system/Database/Live/BadQueryTest.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,22 @@ public function testBadQueryDebugFalse(): void
5353

5454
$this->enableDBDebug();
5555
}
56+
57+
public function testPostgreBadQueryDebugTrueWithWarningsDisabled(): void
58+
{
59+
if ($this->db->DBDriver !== 'Postgre') {
60+
$this->markTestSkipped('This test is only for Postgre.');
61+
}
62+
63+
$this->enableDBDebug();
64+
$errorReporting = error_reporting(E_ALL & ~E_WARNING);
65+
66+
try {
67+
$this->expectException(DatabaseException::class);
68+
$this->expectExceptionMessage('table_does_not_exist');
69+
$this->db->query('SELECT * FROM table_does_not_exist');
70+
} finally {
71+
error_reporting($errorReporting);
72+
}
73+
}
5674
}

‎tests/system/Validation/StrictRules/CreditCardRulesTest.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ public static function provideValidCCNumber(): iterable
100100
'abcd efgh ijkl mnop',
101101
false,
102102
],
103+
'decimal_point_visa' => [
104+
'visa',
105+
'41.1111111111111',
106+
false,
107+
],
108+
'decimal_point_mastercard' => [
109+
'mastercard',
110+
'5351367.37861108',
111+
false,
112+
],
103113
'bad_length' => [
104114
'amex',
105115
'3782 8224 6310 0051',

0 commit comments

Comments
 (0)