• Resolved Saul F

    (@saulbw)


    Some silly plugins actually check or enforce that $wpdb is an instance of the wpdb class, which does kind of make sense if you prefer strict code. But in the case of WP DB Driver, $wpdb is set to an instance of the wpdb_drivers class, so this test fails.

    These checks could be in the form of:

    function my_func(wpdb $wpdb) {
        ...
    }

    Or just:

    if ($wpdb instanceof wpdb) {
        ...
    }

    To circumvent this, wouldn’t it be a good idea to extend the wpdb_drivers class from the wpdb class? This would solve any issues like this with other plugins, and also make it more semantic.

    What do you think?

    https://wordpress.org/plugins/wp-db-driver/

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘$wpdb Not Instance of wpdb’ is closed to new replies.