PostgreSQL-For-Wordpress / postgresql-for-wordpress

A maintained fork of https://wordpress.org/plugins/postgresql-for-wordpress/
GNU General Public License v2.0
234 stars 73 forks source link

Deprecated and Warning during wp core install (wp cli command) #113

Open SamTyurenkov opened 8 months ago

SamTyurenkov commented 8 months ago

Maybe this is already fixed, didnt test with latest master yet.

WP Version: 6.4.3 PG4WP Version: master downloaded in january 2024

Error:

wp core install --url=https://test.test --title="TEST TEST" --admin_user=admin --admin_password=password --admin_email=my@email.com --allow-root
Deprecated: pg_query(): Automatic fetching of PostgreSQL connection is deprecated in /var/www/site/web/app/pg4wp/driver_pgsql_rewrite.php on line 95
Warning: pg_query(): Query failed: ERROR:  relation "wp_posts_id_seq" does not exist
LINE 1: SELECT SETVAL('wp_posts_ID_seq',(SELECT MAX("ID") FROM wp_po...
                      ^ in /var/www/site/web/app/pg4wp/driver_pgsql_rewrite.php on line 95
sh: 1: /usr/sbin/sendmail: not found
Success: WordPress installed successfully.

Basically wordpress seems to be installed, but there was a Deprecated and Warning.

mattbucci commented 8 months ago

I haven't tested this yet either tbh but I'm hopeful it was fixed by https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress/pull/101

There's a few bugs in 3.4 to patch though before re-testing deeper, most notably the regex case insensitive change mentioned here: https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress/issues/109#issuecomment-1989150761

mattbucci commented 8 months ago

Deprecated issue still exists, this is a change which can be added to 3.4.1

This line could be changed to pull connection from the global variable, but actually I think this line should not be there https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress/blob/c7e3fbd50bb5363c84b39a611f65b9c699c7f63f/pg4wp/driver_pgsql_rewrite.php#L95

This is the rewrite class and as such any calls to pg_ should not live here. This seems to be the only such case and is left in by accident.

I think instead maybe this code can be moved to https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress/blob/c7e3fbd50bb5363c84b39a611f65b9c699c7f63f/pg4wp/driver_pgsql.php#L559

Maybe wpsqli_query could be recursive so at the bottom it would contain

if(isset($GLOBALS['pg4wp_queued_query'])) {
        $queuedSQL = $GLOBALS['pg4wp_queued_query'];
        unset($GLOBALS['pg4wp_queued_query']);
        wpsqli_query($connection, $queuedSQL, $result_mode);
        pg_query($GLOBALS['pg4wp_queued_query']);
    }