Skip to content

Commit db17a77

Browse files
committed
fix: _escapeString() should accept Stringable
1 parent 0d1c6b9 commit db17a77

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

system/Database/BaseConnection.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use CodeIgniter\Database\Exceptions\DatabaseException;
1818
use CodeIgniter\Events\Events;
1919
use stdClass;
20+
use Stringable;
2021
use Throwable;
2122

2223
/**
@@ -1328,8 +1329,8 @@ public function escape($str)
13281329
/**
13291330
* Escape String
13301331
*
1331-
* @param list<string>|string $str Input string
1332-
* @param bool $like Whether or not the string will be used in a LIKE condition
1332+
* @param list<string|Stringable>|string|Stringable $str Input string
1333+
* @param bool $like Whether the string will be used in a LIKE condition
13331334
*
13341335
* @return list<string>|string
13351336
*/
@@ -1371,7 +1372,7 @@ public function escapeString($str, bool $like = false)
13711372
* Calls the individual driver for platform
13721373
* specific escaping for LIKE conditions
13731374
*
1374-
* @param list<string>|string $str
1375+
* @param list<string|Stringable>|string|Stringable $str
13751376
*
13761377
* @return list<string>|string
13771378
*/
@@ -1385,7 +1386,7 @@ public function escapeLikeString($str)
13851386
*
13861387
* Will likely be overridden in child classes.
13871388
*/
1388-
protected function _escapeString(string $str): string
1389+
protected function _escapeString(string|Stringable $str): string
13891390
{
13901391
return str_replace("'", "''", remove_invisible_characters($str, false));
13911392
}

system/Database/MySQLi/Connection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use mysqli_result;
2121
use mysqli_sql_exception;
2222
use stdClass;
23+
use Stringable;
2324
use Throwable;
2425

2526
/**
@@ -342,7 +343,7 @@ public function affectedRows(): int
342343
/**
343344
* Platform-dependant string escape
344345
*/
345-
protected function _escapeString(string $str): string
346+
protected function _escapeString(string|Stringable $str): string
346347
{
347348
if (! $this->connID) {
348349
$this->initialize();

system/Database/Postgre/Connection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use PgSql\Connection as PgSqlConnection;
2121
use PgSql\Result as PgSqlResult;
2222
use stdClass;
23+
use Stringable;
2324

2425
/**
2526
* Connection for Postgre
@@ -253,7 +254,7 @@ public function escape($str)
253254
/**
254255
* Platform-dependant string escape
255256
*/
256-
protected function _escapeString(string $str): string
257+
protected function _escapeString(string|Stringable $str): string
257258
{
258259
if (! $this->connID) {
259260
$this->initialize();

system/Database/SQLSRV/Connection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use CodeIgniter\Database\BaseConnection;
1717
use CodeIgniter\Database\Exceptions\DatabaseException;
1818
use stdClass;
19+
use Stringable;
1920

2021
/**
2122
* Connection for SQLSRV
@@ -182,7 +183,7 @@ protected function _close()
182183
/**
183184
* Platform-dependant string escape
184185
*/
185-
protected function _escapeString(string $str): string
186+
protected function _escapeString(string|Stringable $str): string
186187
{
187188
return str_replace("'", "''", remove_invisible_characters($str, false));
188189
}

system/Database/SQLite3/Connection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use SQLite3;
2020
use SQLite3Result;
2121
use stdClass;
22+
use Stringable;
2223

2324
/**
2425
* Connection for SQLite3
@@ -171,7 +172,7 @@ public function affectedRows(): int
171172
/**
172173
* Platform-dependant string escape
173174
*/
174-
protected function _escapeString(string $str): string
175+
protected function _escapeString(string|Stringable $str): string
175176
{
176177
if (! $this->connID instanceof SQLite3) {
177178
$this->initialize();

0 commit comments

Comments
 (0)