Skip to content

Commit f945e4e

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.8
# Conflicts: # tests/system/Database/BaseConnectionTest.php
2 parents 658e1a5 + c0c7792 commit f945e4e

File tree

7 files changed

+57
-17
lines changed

7 files changed

+57
-17
lines changed

system/Database/BaseConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1524,7 +1524,7 @@ public function callFunction(string $functionName, ...$params): bool
15241524
{
15251525
$driver = $this->getDriverFunctionPrefix();
15261526

1527-
if (! str_contains($driver, $functionName)) {
1527+
if (! str_starts_with($functionName, $driver)) {
15281528
$functionName = $driver . $functionName;
15291529
}
15301530

system/I18n/TimeTrait.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,19 +1238,11 @@ public function __isset($name): bool
12381238

12391239
/**
12401240
* This is called when we unserialize the Time object.
1241+
*
1242+
* @param array{date: string, timezone: string, timezone_type: int} $data
12411243
*/
1242-
public function __wakeup(): void
1244+
public function __unserialize(array $data): void
12431245
{
1244-
/**
1245-
* Prior to unserialization, this is a string.
1246-
*
1247-
* @var string $timezone
1248-
*/
1249-
$timezone = $this->timezone;
1250-
1251-
$this->timezone = new DateTimeZone($timezone);
1252-
1253-
// @phpstan-ignore-next-line `$this->date` is a special property for PHP internal use.
1254-
parent::__construct($this->date, $this->timezone);
1246+
parent::__construct($data['date'], new DateTimeZone($data['timezone']));
12551247
}
12561248
}

system/View/View.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,10 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
202202
$this->renderVars['file'] = $this->viewPath . $this->renderVars['view'];
203203

204204
if (str_contains($this->renderVars['view'], '\\')) {
205-
$overrideFolder = $this->config->appOverridesFolder !== ''
206-
? trim($this->config->appOverridesFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR
205+
$appOverridesFolder = $this->config->appOverridesFolder ?? 'overrides';
206+
207+
$overrideFolder = $appOverridesFolder !== ''
208+
? trim($appOverridesFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR
207209
: '';
208210

209211
$this->renderVars['file'] = $this->viewPath

tests/system/Database/BaseConnectionTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,4 +435,28 @@ public function testGetSessionTimezoneWithoutTimezoneKey(): void
435435
$result = $this->getPrivateMethodInvoker($db, 'getSessionTimezone')();
436436
$this->assertNull($result);
437437
}
438+
439+
public function testCallFunctionDoesNotDoublePrefixAlreadyPrefixedName(): void
440+
{
441+
$db = new class ($this->options) extends MockConnection {
442+
protected function getDriverFunctionPrefix(): string
443+
{
444+
return 'str_';
445+
}
446+
};
447+
448+
$this->assertTrue($db->callFunction('str_contains', 'CodeIgniter', 'Ignite'));
449+
}
450+
451+
public function testCallFunctionPrefixesUnprefixedName(): void
452+
{
453+
$db = new class ($this->options) extends MockConnection {
454+
protected function getDriverFunctionPrefix(): string
455+
{
456+
return 'str_';
457+
}
458+
};
459+
460+
$this->assertTrue($db->callFunction('contains', 'CodeIgniter', 'Ignite'));
461+
}
438462
}

user_guide_src/source/changelogs/v4.7.1.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ Bugs Fixed
4040

4141
- **ContentSecurityPolicy:** Fixed a bug where custom CSP tags were not removed from generated HTML when CSP was disabled. The method now ensures that all custom CSP tags are removed from the generated HTML.
4242
- **ContentSecurityPolicy:** Fixed a bug where ``generateNonces()`` produces corrupted JSON responses by replacing CSP nonce placeholders with unescaped double quotes. The method now automatically JSON-escapes nonce attributes when the response Content-Type is JSON.
43+
- **Database:** Fixed a bug where ``BaseConnection::callFunction()`` could double-prefix already-prefixed function names.
4344
- **Model:** Fixed a bug where ``BaseModel::updateBatch()`` threw an exception when ``updateOnlyChanged`` was ``true`` and the index field value did not change.
4445
- **Session:** Fixed a bug in ``MemcachedHandler`` where the constructor incorrectly threw an exception when ``savePath`` was not empty.
4546
- **Toolbar:** Fixed a bug where the standalone toolbar page loaded from ``?debugbar_time=...`` was not interactive.
47+
- **View:** Fixed a bug where ``View`` would throw an error if the ``appOverridesFolder`` config property was not defined.
4648

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

utils/phpstan-baseline/loader.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 2122 errors
1+
# total 2126 errors
22

33
includes:
44
- argument.type.neon

utils/phpstan-baseline/method.childParameterType.neon

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 8 errors
1+
# total 12 errors
22

33
parameters:
44
ignoreErrors:
@@ -41,3 +41,23 @@ parameters:
4141
message: '#^Parameter \#1 \$value \(int\) of method CodeIgniter\\Entity\\Cast\\IntBoolCast\:\:get\(\) should be contravariant with parameter \$value \(array\|bool\|float\|int\|object\|string\|null\) of method CodeIgniter\\Entity\\Cast\\CastInterface\:\:get\(\)$#'
4242
count: 1
4343
path: ../../system/Entity/Cast/IntBoolCast.php
44+
45+
-
46+
message: '#^Parameter \#1 \$data \(array\{date\: string, timezone\: string, timezone_type\: int\}\) of method CodeIgniter\\I18n\\Time\:\:__unserialize\(\) should be contravariant with parameter \$data \(array\) of method DateTimeImmutable\:\:__unserialize\(\)$#'
47+
count: 1
48+
path: ../../system/I18n/Time.php
49+
50+
-
51+
message: '#^Parameter \#1 \$data \(array\{date\: string, timezone\: string, timezone_type\: int\}\) of method CodeIgniter\\I18n\\Time\:\:__unserialize\(\) should be contravariant with parameter \$data \(array\) of method DateTimeInterface\:\:__unserialize\(\)$#'
52+
count: 1
53+
path: ../../system/I18n/Time.php
54+
55+
-
56+
message: '#^Parameter \#1 \$data \(array\{date\: string, timezone\: string, timezone_type\: int\}\) of method CodeIgniter\\I18n\\TimeLegacy\:\:__unserialize\(\) should be contravariant with parameter \$data \(array\) of method DateTimeInterface\:\:__unserialize\(\)$#'
57+
count: 1
58+
path: ../../system/I18n/TimeLegacy.php
59+
60+
-
61+
message: '#^Parameter \#1 \$data \(array\{date\: string, timezone\: string, timezone_type\: int\}\) of method CodeIgniter\\I18n\\TimeLegacy\:\:__unserialize\(\) should be contravariant with parameter \$data \(array\) of method DateTime\:\:__unserialize\(\)$#'
62+
count: 1
63+
path: ../../system/I18n/TimeLegacy.php

0 commit comments

Comments
 (0)