]> git.mjollnir.org Git - moodle.git/commitdiff
strip "old" harcoded "limit" clauses from the sql passed and
authorstronk7 <stronk7>
Mon, 23 Oct 2006 07:46:10 +0000 (07:46 +0000)
committerstronk7 <stronk7>
Mon, 23 Oct 2006 07:46:10 +0000 (07:46 +0000)
debug about them. MDL-7173

Merged from MOODLE_17_STABLE

lib/dmllib.php

index 2907fc658e5343aba29f47c8f5dfedd5285438a5..e9e4a1b65c0fa29cfb5462c03fecea0d03bc8dd4 100644 (file)
@@ -894,6 +894,13 @@ function get_field_select($table, $return, $select) {
 function get_field_sql($sql) {
     global $CFG;
 
+/// Strip potential LIMIT uses arriving here, debugging them (MDL-7173)
+    $newsql = preg_replace('/ LIMIT [0-9, ]+$/is', '', $sql);
+    if ($newsql != $sql) {
+        debugging('Incorrect use of LIMIT clause (not cross-db) in call to get_field_sql(): ' . $sql, DEBUG_DEVELOPER);
+        $sql = $newsql;
+    }
+
     $rs = get_recordset_sql($sql, 0, 1);
 
     if ($rs && $rs->RecordCount() == 1) {