From f3a28ab91f565fe04c71ac43e29da2829cb78004 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Tue, 25 Oct 2016 17:00:50 +0100 Subject: [PATCH] Applied fixes from StyleCI (#10) [ci skip] [skip ci]--- src/Providers/WordpressServiceProvider.php | 1 - src/Proxy/WordpressDatabase.php | 71 ++++++++++++++++++++++++++++++++++++++--------------------------------- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/Providers/WordpressServiceProvider.php b/src/Providers/WordpressServiceProvider.php index 62dc52b..93ec772 100644 --- a/src/Providers/WordpressServiceProvider.php +++ a/src/Providers/WordpressServiceProvider.php @@ -1,9 +1,8 @@ incompatible_modes); foreach ($modes as $i => $mode) { - if (in_array($mode, $incompatible_modes)) { + if (in_array($mode, $incompatible_modes, true)) { unset($modes[$i]); } } @@ -98,50 +99,19 @@ } /** - * Real escape, using mysqli_real_escape_string() or mysql_real_escape_string() + * Real escape, using mysqli_real_escape_string() or mysql_real_escape_string(). * * @see mysqli_real_escape_string() * @see mysql_real_escape_string() * @since 2.8.0 - * @access private * * @param string $string to escape + * * @return string escaped */ public function _real_escape($string) { return substr(DB::getPdo()->quote($string), 1, -1); - } - - /** - * Internal function to perform the mysql_query() call. - * - * @since 3.9.0 - * - * @access private - * @see wpdb::query() - * - * @param string $query The query to run. - */ - private function _do_query($query) - { - if (defined('SAVEQUERIES') && SAVEQUERIES) { - $this->timer_start(); - } - - if (preg_match('/^\s*(insert|create|alter|truncate|drop)\s/i', $query)) { - $this->last_result = $this->result = DB::statement($query); - } elseif (preg_match('/^\s*(delete|update|replace)\s/i', $query)) { - $this->last_result = $this->result = DB::affectingStatement($query); - } else { - $this->last_result = $this->result = DB::select($query); - } - - $this->num_queries++; - - if (defined('SAVEQUERIES') && SAVEQUERIES) { - $this->queries[] = array($query, $this->timer_stop(), $this->get_caller()); - } } /** @@ -152,12 +122,14 @@ * @since 0.71 * * @param string $query Database query + * * @return int|false Number of rows affected/selected or false on error */ public function query($query) { if (!$this->ready) { $this->check_current_query = true; + return false; } @@ -186,6 +158,7 @@ $this->flush(); if ($stripped_query !== $query) { $this->insert_id = 0; + return false; } } @@ -206,6 +179,7 @@ } $this->print_error($this->last_error); + return false; } @@ -221,5 +195,34 @@ } return $return_val; + } + + /** + * Internal function to perform the mysql_query() call. + * + * @since 3.9.0 + * @see wpdb::query() + * + * @param string $query The query to run. + */ + private function _do_query($query) + { + if (defined('SAVEQUERIES') && SAVEQUERIES) { + $this->timer_start(); + } + + if (preg_match('/^\s*(insert|create|alter|truncate|drop)\s/i', $query)) { + $this->last_result = $this->result = DB::statement($query); + } elseif (preg_match('/^\s*(delete|update|replace)\s/i', $query)) { + $this->last_result = $this->result = DB::affectingStatement($query); + } else { + $this->last_result = $this->result = DB::select($query); + } + + $this->num_queries++; + + if (defined('SAVEQUERIES') && SAVEQUERIES) { + $this->queries[] = [$query, $this->timer_stop(), $this->get_caller()]; + } } } -- rgit 0.1.5