[wp-trac] [WordPress Trac] #64523: _do_query needs exception processing in class-wpdb.php
WordPress Trac
noreply at wordpress.org
Fri Jan 16 21:40:39 UTC 2026
#64523: _do_query needs exception processing in class-wpdb.php
--------------------------+-----------------------------
Reporter: randem06 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 6.9
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
When some plugins are loaded with error handling other plugins create
exceptions with ex. "DESCRIBE" statements for tables that do not exist and
an exception occurs, but does not when plugin is not loaded. Happens with
Litespeed or most cache plugins and BotBanish.
**Original Code**
{{{#!php
<?php
private function _do_query( $query ) {
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
$this->timer_start();
}
if ( ! empty( $this->dbh ) ) {
$this->result = mysqli_query( $this->dbh, $query
);
}
++$this->num_queries;
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
$this->log_query(
$query,
$this->timer_stop(),
$this->get_caller(),
$this->time_start,
array()
);
}
}
}}}
**Should be something like**
{{{#!php
<?php
private function _do_query( $query ) {
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
$this->timer_start();
}
** if ( ! empty( $this->dbh ) ) {
try {
$this->result = mysqli_query( $this->dbh, $query
);
} catch (Exception $f) {
// process exception here...
}
}**
++$this->num_queries;
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
$this->log_query(
$query,
$this->timer_stop(),
$this->get_caller(),
$this->time_start,
array()
);
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64523>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list