: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Detect whether or not the string represents a function call and if so
* do not wrap it in single-quotes, otherwise do wrap in single quotes.
* @param string $text The string.
* @return bool Whether or not it's a SQL function call.
private function is_sql_method_call( $text ) {
if ( \substr( $text, -2, 2 ) === '()' ) {
* Checks if a transaction is active.
private function in_transaction() {
return $this->in_transaction;
* @throws Exception If a transaction was already started.
private function begin_transaction() {
if ( $this->in_transaction === true ) {
throw new Exception( 'Transaction already started' );
$wpdb->query( 'START TRANSACTION' );
$this->in_transaction = true;
* @throws Exception If no transaction was strated.
private function commit() {
if ( $this->in_transaction === false ) {
throw new Exception( 'Transaction not started' );
$wpdb->query( 'COMMIT' );
$this->in_transaction = false;
* Rollbacks a transaction.
* @throws Exception If no transaction was started.
private function rollback() {
if ( $this->in_transaction === false ) {
throw new Exception( 'Transaction not started' );
$wpdb->query( 'ROLLBACK' );
$this->in_transaction = false;