-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: BaseConnection::_escapeString()
should accept Stringable
#8739
fix: BaseConnection::_escapeString()
should accept Stringable
#8739
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I took a practical test, everything seems to work fine.
@kenjis shield support 7.4+ but Stringable is php>8 , how about? |
@datamweb No problem. If a user uses PHP 7.4, composer installs CI 4.4. |
ad23ec6
to
db17a77
Compare
db17a77
to
4825f89
Compare
Added docs. |
@@ -20,6 +20,10 @@ Mandatory File Changes | |||
Breaking Changes | |||
**************** | |||
|
|||
- **QueryBuilder:** Due to a bug fix, the parameter type of ``BaseBuilder::_escapeString()`` | |||
has been changed from ``string`` to ``string|Stringable``. If you are extending | |||
this method, update the method paramtere type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: paramtere - parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Done.
@@ -182,7 +183,7 @@ protected function _close() | |||
/** | |||
* Platform-dependant string escape | |||
*/ | |||
protected function _escapeString(string $str): string | |||
protected function _escapeString(string|Stringable $str): string | |||
{ | |||
return str_replace("'", "''", remove_invisible_characters($str, false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does remove_invisible_characters
also allow Stringable
?
@@ -253,7 +254,7 @@ public function escape($str) | |||
/** | |||
* Platform-dependant string escape | |||
*/ | |||
protected function _escapeString(string $str): string | |||
protected function _escapeString(string|Stringable $str): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question for pg_escape_string
.
I think we need to add a string cast to both function calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the good insight!
BaseBuilder::_escapeString()
should accept StringableBaseConnection::_escapeString()
should accept Stringable
Go to #8756 |
Description
It was accepted in 4.4 because of no strict types.
In 4.5, Stringable should be also accepted.
See also codeigniter4/shield#1092
Checklist: