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
Closed

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

cottton opened this issue Aug 26, 2019 · 12 comments
Assignees
Labels
bug A bug report status: low Low

Comments

@cottton
Copy link
Contributor

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
Copy link
Member

What Phalcon version are you on?

@cottton
Copy link
Contributor Author

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.

@sergeyklay
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

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 mentioned this issue Sep 3, 2019
5 tasks
@cottton
Copy link
Contributor Author

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
Copy link
Contributor

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.

@GammaGames
Copy link

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
Copy link
Member

@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
Copy link
Contributor

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
Copy link

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
Copy link
Contributor

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

@niden niden added bug A bug report status: low Low and removed Bug - Low labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: low Low
Projects
None yet
Development

No branches or pull requests

6 participants