From d84336c27db65949bed04df8799dfb893015f487 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Fri, 5 Aug 2011 21:33:16 +0200 Subject: [PATCH] verify where_clause() only in debug mode --- lib/dml/moodle_database.php | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/dml/moodle_database.php b/lib/dml/moodle_database.php index 83885c3bcf1..db88a9efe7b 100644 --- a/lib/dml/moodle_database.php +++ b/lib/dml/moodle_database.php @@ -502,19 +502,24 @@ abstract class moodle_database { $where = array(); $params = array(); - $columns = $this->get_columns($table); + if (debugging()) { + $columns = $this->get_columns($table); + foreach ($conditions as $key=>$value) { + if (!isset($columns[$key])) { + $a = new stdClass(); + $a->fieldname = $key; + $a->tablename = $table; + throw new dml_exception('ddlfieldnotexist', $a); + } + $column = $columns[$key]; + if ($column->meta_type == 'X') { + //ok so the column is a text column. sorry no text columns in the where clause conditions + throw new dml_exception('textconditionsnotallowed', $conditions); + } + } + } + foreach ($conditions as $key=>$value) { - if (!isset($columns[$key])) { - $a = new stdClass(); - $a->fieldname = $key; - $a->tablename = $table; - throw new dml_exception('ddlfieldnotexist', $a); - } - $column = $columns[$key]; - if ($column->meta_type == 'X') { - //ok so the column is a text column. sorry no text columns in the where clause conditions - throw new dml_exception('textconditionsnotallowed', $conditions); - } if (is_int($key)) { throw new dml_exception('invalidnumkey'); }