Skip to content

check_connection fails #161

Description

@Yogurt4

WP Version: 6.8.3
PG4WP Version: 3.4.1

Error:

Fatal error: Uncaught Exception: Invalid or unsupported SQL statement. in /var/www/html/wp-content/pg4wp/driver_pgsql_rewrite.php:26
Stack trace:
#0 /var/www/html/wp-content/pg4wp/driver_pgsql_rewrite.php(40): createSQLRewriter('DO 1')
#1 /var/www/html/wp-content/pg4wp/driver_pgsql.php(523): pg4wp_rewrite('DO 1')
#2 /var/www/html/wp-content/pg4wp/core.php(34) : eval()'d code(2124): wpsqli_query(Object(PgSql\Connection), 'DO 1')
#3 /var/www/html/wp-content/plugins/health-endpoint/health-endpoint.php(60): wpdb2->check_connection(false)
#4 /var/www/html/wp-includes/class-wp-hook.php(324): health_check_request(Object(WP))
#5 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#6 /var/www/html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#7 /var/www/html/wp-includes/class-wp.php(418): do_action_ref_array('parse_request', Array)
#8 /var/www/html/wp-includes/class-wp.php(818): WP->parse_request('')
#9 /var/www/html/wp-includes/functions.php(1342): WP->main('')
#10 /var/www/html/wp-blog-header.php(16): wp()
#11 /var/www/html/index.php(17): require('/var/www/html/w...')
#12 {main}
  thrown in /var/www/html/wp-content/pg4wp/driver_pgsql_rewrite.php on line 26

RAW SQL

DO 1

Expected Rewritten SQL

SELECT 1

or

DO $$ BEGIN NULL; END $$

Actual Rewritten SQL

DO 1

This statement is created by the WP core class-wpdb.php, in function check_connection().

As a quick fix, I've added

   if ($sql === 'DO 1')
       return 'SELECT 1;';

to the start of pg4wp_rewrite().

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions