Skip to content
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

RuntimeException: Trying to call method upper on a non-object #14330

Closed
cottton opened this issue Aug 26, 2019 · 12 comments
Assignees
Labels

Comments

@cottton
Copy link
Contributor

@cottton cottton commented Aug 26, 2019

See #11466 (comment)

This is my fault: #13010

See

if typeof key == "string" && defined("\PDO::" . key->upper()) {

/**
 * 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 :/

@ruudboon

This comment has been minimized.

Copy link
Member

@ruudboon ruudboon commented Aug 26, 2019

What Phalcon version are you on?

@cottton

This comment has been minimized.

Copy link
Contributor Author

@cottton cottton commented Aug 26, 2019

3.4
and this feature was Implemented in the 3.3.x branch. (#13010 (comment))

So 3.3, 3.4 and 4. would need that to be fixed.

@ruudboon ruudboon added this to To do in 4.0 Release via automation Aug 26, 2019
@sergeyklay

This comment has been minimized.

Copy link
Member

@sergeyklay sergeyklay commented Sep 2, 2019

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
@cottton

This comment has been minimized.

Copy link
Contributor Author

@cottton cottton commented Sep 3, 2019

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

@sergeyklay

This comment has been minimized.

Copy link
Member

@sergeyklay sergeyklay commented Sep 3, 2019

IMO better is to replace by "\PDO::" . strtoupper(key)

@ruudboon ruudboon self-assigned this Sep 3, 2019
@ruudboon ruudboon removed the 4.0 label Sep 3, 2019
@ruudboon ruudboon removed this from To do in 4.0 Release Sep 3, 2019
@ruudboon ruudboon referenced this issue Sep 3, 2019
3 of 5 tasks complete
@cottton

This comment has been minimized.

Copy link
Contributor Author

@cottton cottton commented Sep 3, 2019

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';",
    ],
];
@sergeyklay

This comment has been minimized.

Copy link
Member

@sergeyklay sergeyklay commented Sep 4, 2019

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.

@sergeyklay sergeyklay closed this Sep 4, 2019
@GammaGames

This comment has been minimized.

Copy link

@GammaGames GammaGames commented Oct 29, 2019

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.

@Jeckerson

This comment has been minimized.

Copy link
Member

@Jeckerson Jeckerson commented Oct 29, 2019

@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?

@sergeyklay

This comment has been minimized.

Copy link
Member

@sergeyklay sergeyklay commented Oct 29, 2019

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.

@GammaGames

This comment has been minimized.

Copy link

@GammaGames GammaGames commented Oct 30, 2019

@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!

@sergeyklay

This comment has been minimized.

Copy link
Member

@sergeyklay sergeyklay commented Oct 30, 2019

Yeah guys. We've released v3.4.5 right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.