From: skodak Date: Sun, 16 Mar 2008 22:48:39 +0000 (+0000) Subject: MDL-13945 prevent fatal errors in all rs_xx functions; merged from MOODLE_19_STABLE X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f8f1f8076f2a683c25f03da1725b2250c584f1b5;p=moodle.git MDL-13945 prevent fatal errors in all rs_xx functions; merged from MOODLE_19_STABLE --- diff --git a/lib/dmllib.php b/lib/dmllib.php index 25861e11af..c6ab9a7b4d 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -765,9 +765,13 @@ function recordset_to_array($rs) { * @return ADOFetchObj the object containing the fetched information */ function rs_fetch_record(&$rs) { - global $CFG; + if (!$rs) { + debugging('Incorrect $rs used!', DEBUG_DEVELOPER); + return false; + } + $rec = $rs->FetchObj(); //Retrieve record as object without advance the pointer if ($rs->EOF) { //FetchObj requires manual checking of EOF to detect if it's the last record @@ -794,6 +798,10 @@ function rs_fetch_record(&$rs) { * @return boolean true if the movement was successful and false if not (end of recordset) */ function rs_next_record(&$rs) { + if (!$rs) { + debugging('Incorrect $rs used!', DEBUG_DEVELOPER); + return false; + } return $rs->MoveNext(); //Move the pointer to the next record } @@ -816,8 +824,8 @@ function rs_fetch_next_record(&$rs) { global $CFG; - if (empty($rs)) { - debugging('Incorrect rs used!'); + if (!$rs) { + debugging('Incorrect $rs used!', DEBUG_DEVELOPER); return false; } @@ -845,6 +853,10 @@ function rs_fetch_next_record(&$rs) { * @return bool */ function rs_EOF($rs) { + if (!$rs) { + debugging('Incorrect $rs used!', DEBUG_DEVELOPER); + return true; + } return $rs->EOF; } @@ -857,7 +869,7 @@ function rs_EOF($rs) { */ function rs_close(&$rs) { if (!$rs) { - // recordset not open, hmmm + debugging('Incorrect $rs used!', DEBUG_DEVELOPER); return; }