See https://github.com/phalcon/cphalcon/issues/11466#issuecomment-480247019
This is my fault: https://github.com/phalcon/cphalcon/issues/13010
/**
* Check for \PDO::XXX class constant aliases
*/
for key, value in options {
if typeof key == "string" && defined("\PDO::" . key->upper()) {
let options[constant("\PDO::" . key->upper())] = value;
unset options[key];
}
}
EDIT: key->upper() must be something valid in zep (string in key to upper)
Could somebody pls fix this?
I do not have enough knowledge in zep - told ya before :p
Karma i just needed this feature and it shot the error msg right in my face :/
What Phalcon version are you on?
3.4
and this feature was Implemented in the 3.3.x branch. (https://github.com/phalcon/cphalcon/issues/13010#issuecomment-346689104)
So 3.3, 3.4 and 4. would need that to be fixed.
Because for key, value in options will create vars, not strings. In other hand:
var a = "abc";
typeof a; // string
But upper is present for true string datatype, e.g.
string a = "abc";
a->upper(); // ABC
So this
for key, value in options {
let castValue = (string) key;
if typeof key == "string" && defined("\PDO::" . castValue->upper()) {
let options[constant("\PDO::" . castValue->upper())] = value;
unset options[key];
}
}
or this
for key, value in options {
if typeof key == "string" && defined("\PDO::" . (string)key->upper()) {
let options[constant("\PDO::" . (string)key->upper())] = value;
unset options[key];
}
}
?
Still not sure about the rest.
Not going to mess that up twice :D
IMO better is to replace by "\PDO::" . strtoupper(key)
Thanks @ruudboon .
Perhaps a test would be good.
Dont know how to add but it should check
the options (descriptor["options"]) provided in param descriptor :
// test numeric keys like PDO constants does not get changed
// f.e.
// \PDO::MYSQL_ATTR_INIT_COMMAND => ...
// which is
// 1002 => ...
// must not be changed.
$descriptor = [
'options' => [
\PDO::MYSQL_ATTR_INIT_COMMAND => "SET CHARSET 'utf8';",
],
];
// test string keys that match PDO constants does get mapped
// f.e.
// "mysql_attr_init_command" => ...
// which is
// \PDO::MYSQL_ATTR_INIT_COMMAND => ...
// which is
// 1002 => ...
// should be mapped.
$descriptor = [
'options' => [
'mysql_attr_init_command' => "SET CHARSET 'utf8';",
],
];
Fixed in the 3.4.x branch. Feel free to open a new issue if the problem appears again. Thank you for the bug report.
Is there any ETA on the next release? I see the last release was Jun 30, and (from what I can tell) the most recent changeto 3.4.x was this one. I'm attempting to set the application name for a postgresql connection and this is adding a bit of a roadblock.
@GammaGames you can compile from sources 3.4.x branch and use for your project.
But anyway it is strange that new version wasn't released, since there are some changes in it...
@sergeyklay any answers for questions above?
We're not plan to release 3.x in near future. I'm sorry. In other hand, there are simple steps to build Phalcon from source code. This is so easily done that everyone can do it himself. Feel free to ping me in case of any building problem.
@sergeyklay Wait, did you just release a new version? I was attempting to make a docker container that would compile 3.4.x from source!
Yeah guys. We've released v3.4.5 right now
Most helpful comment
Yeah guys. We've released v3.4.5 right now