From 14404f91ea7fe2eb7f222a0afe845e896efc511f Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 22 Aug 2019 16:07:21 +0800 Subject: [PATCH] MDL-66110 dml: Undo table name fix when table name's used as parameter --- lib/dml/mysqli_native_moodle_database.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/dml/mysqli_native_moodle_database.php b/lib/dml/mysqli_native_moodle_database.php index 92b5590e3aa..8469c0d5003 100644 --- a/lib/dml/mysqli_native_moodle_database.php +++ b/lib/dml/mysqli_native_moodle_database.php @@ -326,10 +326,9 @@ class mysqli_native_moodle_database extends moodle_database { $rowformat = null; if (isset($table)) { $table = $this->mysqli->real_escape_string($table); - $fixedtable = $this->fix_table_name($table); $sql = "SELECT row_format FROM INFORMATION_SCHEMA.TABLES - WHERE table_schema = DATABASE() AND table_name = '$fixedtable'"; + WHERE table_schema = DATABASE() AND table_name = '{$this->prefix}$table'"; } else { if ($this->is_antelope_file_format_no_more_supported()) { // Breaking change: Antelope file format support has been removed, only Barracuda. @@ -721,11 +720,10 @@ class mysqli_native_moodle_database extends moodle_database { $structure = array(); - $fixedtable = $this->fix_table_name($table); $sql = "SELECT column_name, data_type, character_maximum_length, numeric_precision, numeric_scale, is_nullable, column_type, column_default, column_key, extra FROM information_schema.columns - WHERE table_name = '" . $fixedtable . "' + WHERE table_name = '" . $this->prefix.$table . "' AND table_schema = '" . $this->dbname . "' ORDER BY ordinal_position"; $this->query_start($sql, null, SQL_QUERY_AUX); @@ -749,6 +747,7 @@ class mysqli_native_moodle_database extends moodle_database { } else { // temporary tables are not in information schema, let's try it the old way $result->close(); + $fixedtable = $this->fix_table_name($table); $sql = "SHOW COLUMNS FROM $fixedtable"; $this->query_start($sql, null, SQL_QUERY_AUX); $result = $this->mysqli->query($sql);