Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions db.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

/*
Plugin Name: HyperDB
Plugin URI: https://wordpress.org/plugins/hyperdb/
Plugin Name: LudacrisDB
Plugin URI: https://github.com/justinmaurerdotdev/HyperDB
Description: An advanced database class that supports replication, failover, load balancing, and partitioning.
Author: Automattic
Author: Automattic, Justin Maurer
License: GPLv2 or later
Version: 1.9
Version: 1.10
*/

// phpcs:disable Squiz.PHP.CommentedOutCode.Found
Expand Down Expand Up @@ -341,7 +341,10 @@ public function get_table_from_query( $q ) {
public function is_write_query( $q ) {
// Quick and dirty: only SELECT statements are considered read-only.
$q = ltrim( $q, "\r\n\t (" );
return ! preg_match( '/^(?:SELECT|SHOW|DESCRIBE|DESC|EXPLAIN)\s/i', $q );
return (
! preg_match( '/^(?:SELECT|SHOW|DESCRIBE|DESC|EXPLAIN)\s/i', $q )
|| preg_match( '/(\sFOR UPDATE)/i', $q )
);
}

/**
Expand Down Expand Up @@ -1444,7 +1447,12 @@ public function ex_mysql_query( $query, $dbh ) {
if ( ! $this->use_mysqli ) {
return mysql_query( $query, $dbh );
}

$driver = new mysqli_driver();
if ($this->suppress_errors) {
$driver->report_mode = MYSQLI_REPORT_OFF;
} else {
$driver->report_mode = MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT;
}
return mysqli_query( $dbh, $query );
}

Expand Down