mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-52060 phpunit: Prevent querying database metadata
This commit is contained in:
parent
22d55b3950
commit
d494306de7
@ -577,6 +577,11 @@ abstract class moodle_database {
|
||||
protected function where_clause($table, array $conditions=null) {
|
||||
// We accept nulls in conditions
|
||||
$conditions = is_null($conditions) ? array() : $conditions;
|
||||
|
||||
if (empty($conditions)) {
|
||||
return array('', array());
|
||||
}
|
||||
|
||||
// Some checks performed under debugging only
|
||||
if (debugging()) {
|
||||
$columns = $this->get_columns($table);
|
||||
@ -600,9 +605,6 @@ abstract class moodle_database {
|
||||
}
|
||||
|
||||
$allowed_types = $this->allowed_param_types();
|
||||
if (empty($conditions)) {
|
||||
return array('', array());
|
||||
}
|
||||
$where = array();
|
||||
$params = array();
|
||||
|
||||
|
@ -1432,9 +1432,9 @@ class core_dml_testcase extends database_driver_testcase {
|
||||
$this->assertSame('ddltablenotexist', $e->errorcode);
|
||||
}
|
||||
}
|
||||
// And without params.
|
||||
|
||||
try {
|
||||
$records = $DB->get_records('xxxx', array());
|
||||
$records = $DB->get_records('xxxx', array('id' => '1'));
|
||||
$this->fail('An Exception is missing, expected due to query against non-existing table');
|
||||
} catch (moodle_exception $e) {
|
||||
$this->assertInstanceOf('dml_exception', $e);
|
||||
@ -5347,7 +5347,7 @@ class core_dml_testcase extends database_driver_testcase {
|
||||
|
||||
// The get_records() method generates 2 queries the first time is called
|
||||
// as it is fetching the table structure.
|
||||
$whatever = $DB->get_records($tablename);
|
||||
$whatever = $DB->get_records($tablename, array('id' => '1'));
|
||||
$this->assertEquals($initreads + 3, $DB->perf_get_reads());
|
||||
$this->assertEquals($initwrites, $DB->perf_get_writes());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user