Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/carson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ settings:
Closing this issue: the description still does not follow the bug report template after {{days_until_close}} days.

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).
- label: waiting for info
days_until_close: 14
unlabel_on_response: true
close_message: |-
Closing this {{type}}: there has been no response for {{days_until_close}} days after more information was requested.

If you can provide the requested details, leave a comment and a maintainer can reopen it.
pr-title-linter:
name: 'Carson / pr-title-linter'
rules:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/run-carson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ on:
- opened
- edited
- labeled
issue_comment:
types:
- created
push:
branches:
- develop
Expand All @@ -28,7 +31,7 @@ jobs:
runs-on: ubuntu-24.04
steps:
- name: Run Carson
uses: NexusPHP/carson@e4b2fde33f32c47455df218cf1765702c15c3b8b # v1.6.0
uses: NexusPHP/carson@cb35604ab330c2e44dba673fcef712c78e75f858 # v1.7.0
with:
app_id: ${{ secrets.CARSON_APP_ID }}
private_key: ${{ secrets.CARSON_PRIVATE_KEY }}
Expand Down
8 changes: 7 additions & 1 deletion system/Database/Postgre/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,13 @@ public function getVersion(): string
protected function execute(string $sql)
{
try {
return pg_query($this->connID, $sql);
$result = pg_query($this->connID, $sql);

if ($result === false && $this->DBDebug) {
throw new DatabaseException(pg_last_error($this->connID));
}

return $result;
} catch (ErrorException $e) {
$trace = array_slice($e->getTrace(), 2); // remove the call to error handler

Expand Down
14 changes: 9 additions & 5 deletions system/Database/ResultInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@ interface ResultInterface
* individual data rows, which can be either an 'array', an
* 'object', or a custom class name.
*
* @param string $type The row type. Either 'array', 'object', or a class name to use
* @template T of object
*
* @param 'array'|'object'|class-string<T> $type The row type. Either 'array', 'object', or a class name to use
*
* @return ($type is 'array' ? list<array<string, mixed>> : ($type is 'object' ? list<stdClass> : list<object>))
* @return ($type is 'array' ? list<array<string, mixed>> : ($type is 'object' ? list<stdClass> : list<T>))
*/
public function getResult(string $type = 'object'): array;

/**
* Returns the results as an array of custom objects.
*
* @param string $className The name of the class to use.
* @template T of object
*
* @param class-string<T> $className The name of the class to use.
*
* @return list<object>
* @return list<T>
*/
public function getCustomResultObject(string $className);

Expand Down Expand Up @@ -102,7 +106,7 @@ public function getRowArray(int $n = 0);
*
* If row doesn't exist, returns null.
*
* @return object|stdClass|null
* @return stdClass|null
*/
public function getRowObject(int $n = 0);

Expand Down
12 changes: 6 additions & 6 deletions system/HTTP/CLIRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function isCLI(): bool
* @param int|null $filter A filter name to apply.
* @param array<string, mixed>|int|null $flags
*
* @return array{}|null
* @return ($index is string ? null : array{})
*/
public function getGet($index = null, $filter = null, $flags = null)
{
Expand All @@ -250,7 +250,7 @@ public function getGet($index = null, $filter = null, $flags = null)
* @param int|null $filter A filter name to apply
* @param array<string, mixed>|int|null $flags
*
* @return array{}|null
* @return ($index is string ? null : array{})
*/
public function getPost($index = null, $filter = null, $flags = null)
{
Expand All @@ -264,7 +264,7 @@ public function getPost($index = null, $filter = null, $flags = null)
* @param int|null $filter A filter name to apply
* @param array<string, mixed>|int|null $flags
*
* @return array{}|null
* @return ($index is string ? null : array{})
*/
public function getPostGet($index = null, $filter = null, $flags = null)
{
Expand All @@ -278,7 +278,7 @@ public function getPostGet($index = null, $filter = null, $flags = null)
* @param int|null $filter A filter name to apply
* @param array<string, mixed>|int|null $flags
*
* @return array{}|null
* @return ($index is string ? null : array{})
*/
public function getGetPost($index = null, $filter = null, $flags = null)
{
Expand All @@ -292,7 +292,7 @@ public function getGetPost($index = null, $filter = null, $flags = null)
* @param int|null $filter A filter name to be applied
* @param mixed $flags
*
* @return array{}|null
* @return ($index is string ? null : array{})
*/
public function getCookie($index = null, $filter = null, $flags = null)
{
Expand All @@ -302,7 +302,7 @@ public function getCookie($index = null, $filter = null, $flags = null)
/**
* @param list<string>|string|null $index
*
* @return array{}|null
* @return ($index is string ? null : array{})
*/
private function returnNullOrEmptyArray($index)
{
Expand Down
4 changes: 2 additions & 2 deletions system/HTTP/IncomingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public function getVar($index = null, $filter = null, $flags = null)
*
* @see http://php.net/manual/en/function.json-decode.php
*
* @return array<array-key, mixed>|bool|float|int|stdClass|null
* @return ($assoc is true ? array<array-key, mixed>|bool|float|int|string|null : array<array-key, mixed>|bool|float|int|stdClass|string|null)
*
* @throws HTTPException When the body is invalid as JSON.
*/
Expand All @@ -430,7 +430,7 @@ public function getJSON(bool $assoc = false, int $depth = 512, int $options = 0)
* @param int|null $filter Filter Constant
* @param array<string, mixed>|int|null $flags Option
*
* @return array<array-key, mixed>|bool|float|int|stdClass|string|null
* @return ($assoc is true ? array<array-key, mixed>|bool|float|int|string|null : array<array-key, mixed>|bool|float|int|stdClass|string|null)
*/
public function getJsonVar($index = null, bool $assoc = false, ?int $filter = null, $flags = null)
{
Expand Down
6 changes: 4 additions & 2 deletions system/Helpers/url_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ function base_url($relativePath = '', ?string $scheme = null): string
* @param bool $returnObject True to return an object instead of a string
* @param IncomingRequest|null $request A request to use when retrieving the path
*
* @return string|URI When returning string, the query and fragment parts are removed.
* When returning URI, the query and fragment parts are preserved.
* @return ($returnObject is true ? URI : string) When returning string, the query and fragment parts are removed.
* When returning URI, the query and fragment parts are preserved.
*/
function current_url(bool $returnObject = false, ?IncomingRequest $request = null): string|URI
{
Expand All @@ -87,6 +87,8 @@ function current_url(bool $returnObject = false, ?IncomingRequest $request = nul
* we first check in a saved session variable, if it exists, and use that.
* If that's not available, however, we'll use a sanitized url from $_SERVER['HTTP_REFERER']
* which can be set by the user so is untrusted and not set by certain browsers/servers.
*
* @return ($returnObject is true ? URI : string)
*/
function previous_url(bool $returnObject = false): string|URI
{
Expand Down
3 changes: 1 addition & 2 deletions system/Validation/CreditCardRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ public function valid_cc_number(?string $ccNumber, string $type): bool
// Remove any spaces and dashes
$ccNumber = str_replace([' ', '-'], '', $ccNumber);

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

Expand Down
18 changes: 18 additions & 0 deletions tests/system/Database/Live/BadQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,22 @@ public function testBadQueryDebugFalse(): void

$this->enableDBDebug();
}

public function testPostgreBadQueryDebugTrueWithWarningsDisabled(): void
{
if ($this->db->DBDriver !== 'Postgre') {
$this->markTestSkipped('This test is only for Postgre.');
}

$this->enableDBDebug();
$errorReporting = error_reporting(E_ALL & ~E_WARNING);

try {
$this->expectException(DatabaseException::class);
$this->expectExceptionMessage('table_does_not_exist');
$this->db->query('SELECT * FROM table_does_not_exist');
} finally {
error_reporting($errorReporting);
}
}
}
10 changes: 10 additions & 0 deletions tests/system/Validation/StrictRules/CreditCardRulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ public static function provideValidCCNumber(): iterable
'abcd efgh ijkl mnop',
false,
],
'decimal_point_visa' => [
'visa',
'41.1111111111111',
false,
],
'decimal_point_mastercard' => [
'mastercard',
'5351367.37861108',
false,
],
'bad_length' => [
'amex',
'3782 8224 6310 0051',
Expand Down
2 changes: 2 additions & 0 deletions user_guide_src/source/changelogs/v4.7.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ Bugs Fixed
- **Cookie:** Fixed a bug where ``Cookie`` instances created with ``raw: true`` allowed invalid characters in cookie values rejected by ``setrawcookie()``.
- **Cookie:** Fixed a bug where ``Cookie`` instances allowed invalid characters in path, domain, and prefix attributes rejected by ``setcookie()`` and ``setrawcookie()``.
- **Database:** Fixed a bug where rebuilding a SQLite3 table (e.g., ``Forge::dropColumn()``, ``Forge::modifyColumn()``, ``Forge::dropForeignKey()`` and ``Forge::dropPrimaryKey()``) corrupted the table names referenced by its foreign keys when ``DBPrefix`` was set.
- **Database:** Fixed a bug where Postgre query failures were silently ignored when ``DBDebug`` was enabled and PHP warnings were disabled. A ``DatabaseException`` is now thrown.
- **Debug:** Fixed a bug where ``Timer::start()`` treated ``0.0`` as an empty value and substituted the current time.
- **Files:** Fixed a bug where ``File::move()`` and ``UploadedFile::move()`` set executable and overly permissive file permissions (``0777 & ~umask()`` instead of ``0666 & ~umask()``), and ``UploadedFile::move()`` targeted the parent directory instead of the destination file for ``chmod()``.
- **Helpers:** Fixed a bug where ``get_dir_file_info()`` returned incomplete entries for subdirectories and missing files instead of omitting them.
- **Honeypot:** Fixed a bug where bot detection returned an HTTP 500 response instead of 403 (Forbidden).
- **I18n:** Fixed a bug where ``Time::today()``, ``Time::yesterday()``, and ``Time::tomorrow()`` ignored the specified ``$timezone`` and ``setTestNow()`` when calculating the day.
- **Logger:** Fixed a bug where interpolating a log message with array or non-stringable context values could raise PHP warnings or errors.
- **Validation:** Fixed a bug where ``valid_cc_number`` accepted non-digit characters (e.g., a decimal point) in the card number. Such values could pass the Luhn check and triggered an ``Undefined array key`` warning inside it; the number is now checked with ``ctype_digit()``.

See the repo's
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_
Expand Down
Loading