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

pear DB.php warning little problem with php 7.2 #1184

Closed
chech66 opened this Issue Sep 19, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@chech66

chech66 commented Sep 19, 2018

There is a little warning problem with pear DB.php in line 774 and php 7.2. While it is not a nominatim problem, to eliminate the messages during the initial importing and then on the server log, it is possible to change the line 774 in /usr/share/pear/DP.php to: if (!$dsn && !count($dsn))

Can Someone confirm this is right?

Regards

@mtmail

This comment has been minimized.

Show comment
Hide comment
@mtmail

mtmail Sep 19, 2018

Collaborator

What is the error/warning message and where do you see it? Is it once or often?

On my Ubuntu18 I haven't seen warning messages, the file location is slightly different and line 774 is empty for me. Is this the lines

        if (!strlen($dsn)) {
            return $parsed;
        }

I don't quite see how the variable could be empty or why PHP 7.2 would treat it different. build/settings/settings.php contains @define('CONST_Database_DSN', 'pgsql://@/nominatim');

Collaborator

mtmail commented Sep 19, 2018

What is the error/warning message and where do you see it? Is it once or often?

On my Ubuntu18 I haven't seen warning messages, the file location is slightly different and line 774 is empty for me. Is this the lines

        if (!strlen($dsn)) {
            return $parsed;
        }

I don't quite see how the variable could be empty or why PHP 7.2 would treat it different. build/settings/settings.php contains @define('CONST_Database_DSN', 'pgsql://@/nominatim');

@mtmail

This comment has been minimized.

Show comment
Hide comment
@mtmail

mtmail Sep 19, 2018

Collaborator

As you say it's outside of the Nominatim code base and we want to move away from what library (#945) so I'm just assessing if it's worth documenting it in our FAQ.

Collaborator

mtmail commented Sep 19, 2018

As you say it's outside of the Nominatim code base and we want to move away from what library (#945) so I'm just assessing if it's worth documenting it in our FAQ.

@chech66

This comment has been minimized.

Show comment
Hide comment
@chech66

chech66 Sep 20, 2018

I forget to mention i am using Centos 7, with php warning messages on. Your line is different from mine, perhaps the DB.php is different....
I have the following line near 774:

    // Get phptype and dbsyntax
    // $str => phptype(dbsyntax)
    if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) {
        $parsed['phptype']  = $arr[1];
        $parsed['dbsyntax'] = !$arr[2] ? $arr[1] : $arr[2];
    } else {
        $parsed['phptype']  = $str;
        $parsed['dbsyntax'] = $str;
    }

    if (!count($dsn)) {
        return $parsed;
    }

    // Get (if found): username and password
    // $dsn => username:password@protocol+hostspec/database
    if (($at = strrpos($dsn,'@')) !== false) {
        $str = substr($dsn, 0, $at);
        $dsn = substr($dsn, $at + 1);

The warning is issued in 7.2 because the function count() has changed slightely... if the value is scalar you have the message.

Your UBUNTU version is different, perhaps is more modern... and 7,2 compatible

chech66 commented Sep 20, 2018

I forget to mention i am using Centos 7, with php warning messages on. Your line is different from mine, perhaps the DB.php is different....
I have the following line near 774:

    // Get phptype and dbsyntax
    // $str => phptype(dbsyntax)
    if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) {
        $parsed['phptype']  = $arr[1];
        $parsed['dbsyntax'] = !$arr[2] ? $arr[1] : $arr[2];
    } else {
        $parsed['phptype']  = $str;
        $parsed['dbsyntax'] = $str;
    }

    if (!count($dsn)) {
        return $parsed;
    }

    // Get (if found): username and password
    // $dsn => username:password@protocol+hostspec/database
    if (($at = strrpos($dsn,'@')) !== false) {
        $str = substr($dsn, 0, $at);
        $dsn = substr($dsn, $at + 1);

The warning is issued in 7.2 because the function count() has changed slightely... if the value is scalar you have the message.

Your UBUNTU version is different, perhaps is more modern... and 7,2 compatible

@chech66

This comment has been minimized.

Show comment
Hide comment
@chech66

chech66 Sep 20, 2018

The warning is the following and happens very very often:

PHP Warning: count(): Parameter must be an array or an object that implements Countable in /usr/share/pear/DB.php on line 774

chech66 commented Sep 20, 2018

The warning is the following and happens very very often:

PHP Warning: count(): Parameter must be an array or an object that implements Countable in /usr/share/pear/DB.php on line 774

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment