From: moodler Date: Sun, 1 Oct 2006 09:16:49 +0000 (+0000) Subject: Adding some serious checks to make Moodle break when there is any X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=937b63ee52b1daf90bb3ddf23bd2ae1ff224eda3;p=moodle.git Adding some serious checks to make Moodle break when there is any select, insert or update on user_students, user_teachers, user_coursecreators, or user_admins (once roles is installed), because they should not be used at all and we will drop them soon. --- diff --git a/lib/dmllib.php b/lib/dmllib.php index 9385f563fb..9644a1ee96 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -607,6 +607,18 @@ function get_recordset_sql($sql, $limitfrom=null, $limitnum=null) { return false; } +/// Temporary hack as part of phasing out all access to obsolete user tables XXX + if (!empty($CFG->rolesactive)) { + if (strpos($sql, $CFG->prefix.'user_students') || + strpos($sql, $CFG->prefix.'user_teachers') || + strpos($sql, $CFG->prefix.'user_coursecreators') || + strpos($sql, $CFG->prefix.'user_admins')) { + if (debugging()) { var_dump(debug_backtrace()); } + error('This SQL relies on obsolete tables! Your code must be fixed by a developer.'); + } + } + + if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++; }; if ($limitfrom || $limitnum) { @@ -1051,6 +1063,14 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') { return false; } +/// Temporary hack as part of phasing out all access to obsolete user tables XXX + if (!empty($CFG->rolesactive)) { + if (in_array($table, array('user_students', 'user_teachers', 'user_coursecreators', 'user_admins'))) { + if (debugging()) { var_dump(debug_backtrace()); } + error('This SQL relies on obsolete tables ('.$table.')! Your code must be fixed by a developer.'); + } + } + if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++; }; /// In Moodle we always use auto-numbering fields for the primary key @@ -1168,6 +1188,14 @@ function update_record($table, $dataobject) { return false; } +/// Temporary hack as part of phasing out all access to obsolete user tables XXX + if (!empty($CFG->rolesactive)) { + if (in_array($table, array('user_students', 'user_teachers', 'user_coursecreators', 'user_admins'))) { + if (debugging()) { var_dump(debug_backtrace()); } + error('This SQL relies on obsolete tables ('.$table.')! Your code must be fixed by a developer.'); + } + } + /// Begin DIRTY HACK if ($CFG->dbtype == 'oci8po') { oracle_dirty_hack($table, $dataobject); // Convert object to the correct "empty" values for Oracle DB