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

$wpdb->suppress_errors() not supressing fatal errors during dbDelta() #139

Closed
dealer-solutions-gene opened this issue Jul 18, 2022 · 3 comments · Fixed by #154
Closed

$wpdb->suppress_errors() not supressing fatal errors during dbDelta() #139

dealer-solutions-gene opened this issue Jul 18, 2022 · 3 comments · Fixed by #154

Comments

@dealer-solutions-gene
Copy link

dealer-solutions-gene commented Jul 18, 2022

After updating the "WP Offload Media" plugin I received this error

Fatal error: Uncaught mysqli_sql_exception: Table 'wordpress.wp_2217_as3cf_items' doesn't exist in /var/www/app/web/app/mu-plugins/ludicrousdb/ludicrousdb/includes/class-ludicrousdb.php:1481

I've tracked it down to a dbDelta() call where the following is being executed, which has been written to ignore failures by the looks of it, eg under the situation where the table doesn't exist, as dbDelta's job is to create or update db tables...

	// Fetch the table column structure from the database.
	$suppress    = $wpdb->suppress_errors();
	$tablefields = $wpdb->get_results( "DESCRIBE {$table};" );
	$wpdb->suppress_errors( $suppress );

the fatal error is generated via the _do_query code in class-ludicrousdb.php

	if ( true === $this->use_mysqli ) {
		$result = mysqli_query( $dbh, $query );
	} else {
		$result = mysql_query( $query, $dbh );
	}

and my "local fix" is to wrap the above in try/catch restoring the check on suppress_errors as crudely as I can think to do it

    try {
        if ( true === $this->use_mysqli ) {
            $result = mysqli_query( $dbh, $query );
        } else {
            $result = mysql_query( $query, $dbh );
        }
    }
    catch ( Throwable $exception ) {
        if( $this->suppress_errors ) {
            $result = false;
        } else {
            throw $exception;
        }
    }
giuscia pushed a commit to seed-glauco/ludicrousdb that referenced this issue Oct 20, 2022
@thd-fox
Copy link

thd-fox commented Nov 9, 2022

I'm facing this issue also! The fix is not doing enough. Is there any additional fix in progress?

@dealer-solutions-gene
Copy link
Author

dealer-solutions-gene commented Nov 9, 2022

@thd-fox Given this project's last release was Dec 5, 2020 I think this one's dead 🤕

@thd-fox
Copy link

thd-fox commented Nov 10, 2022

@dealer-solutions-gene Do you know any other $wpdb scaling replacement? Better than HyperDB or this one?

JJJ added a commit that referenced this issue Apr 23, 2024
This allows errors to be explicitly suppressed when a query fails.

See: #139.
@JJJ JJJ closed this as completed in #154 Apr 23, 2024
JJJ added a commit that referenced this issue Apr 23, 2024
This allows errors to be explicitly suppressed when a query fails.

Fixes #139.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants