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
2 changes: 1 addition & 1 deletion system/Database/BaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ public function callFunction(string $functionName, ...$params): bool
{
$driver = $this->getDriverFunctionPrefix();

if (! str_contains($driver, $functionName)) {
if (! str_starts_with($functionName, $driver)) {
$functionName = $driver . $functionName;
}

Expand Down
24 changes: 24 additions & 0 deletions tests/system/Database/BaseConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,28 @@ public static function provideEscapeIdentifier(): iterable
'with dots' => ['com.sitedb.web', '"com.sitedb.web"'],
];
}

public function testCallFunctionDoesNotDoublePrefixAlreadyPrefixedName(): void
{
$db = new class ($this->options) extends MockConnection {
protected function getDriverFunctionPrefix(): string
{
return 'str_';
}
};

$this->assertTrue($db->callFunction('str_contains', 'CodeIgniter', 'Ignite'));
}

public function testCallFunctionPrefixesUnprefixedName(): void
{
$db = new class ($this->options) extends MockConnection {
protected function getDriverFunctionPrefix(): string
{
return 'str_';
}
};

$this->assertTrue($db->callFunction('contains', 'CodeIgniter', 'Ignite'));
}
}
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.7.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Bugs Fixed

- **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.
- **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.
- **Database:** Fixed a bug where ``BaseConnection::callFunction()`` could double-prefix already-prefixed function names.
- **Model:** Fixed a bug where ``BaseModel::updateBatch()`` threw an exception when ``updateOnlyChanged`` was ``true`` and the index field value did not change.
- **Session:** Fixed a bug in ``MemcachedHandler`` where the constructor incorrectly threw an exception when ``savePath`` was not empty.
- **Toolbar:** Fixed a bug where the standalone toolbar page loaded from ``?debugbar_time=...`` was not interactive.
Expand Down
Loading