From 3f2efc20addb0cc8ee5374a8e4011faaf7aa4ccf Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Wed, 12 Jan 2011 15:35:33 +0100 Subject: [PATCH] MDL-25708 recordsets - page and quiz modules --- mod/page/db/upgradelib.php | 26 ++++++++++++-------------- mod/quiz/lib.php | 5 +++-- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/mod/page/db/upgradelib.php b/mod/page/db/upgradelib.php index 3a159b61d16..3ffeb7aa366 100644 --- a/mod/page/db/upgradelib.php +++ b/mod/page/db/upgradelib.php @@ -51,24 +51,22 @@ function page_20_migrate() { $fs = get_file_storage(); - if ($candidates = $DB->get_recordset('resource_old', array('type'=>'html', 'migrated'=>0))) { - foreach ($candidates as $candidate) { - page_20_migrate_candidate($candidate, $fs, FORMAT_HTML); - } - $candidates->close(); + $candidates = $DB->get_recordset('resource_old', array('type'=>'html', 'migrated'=>0)); + foreach ($candidates as $candidate) { + page_20_migrate_candidate($candidate, $fs, FORMAT_HTML); } + $candidates->close(); - if ($candidates = $DB->get_recordset('resource_old', array('type'=>'text', 'migrated'=>0))) { - foreach ($candidates as $candidate) { - //there might be some rubbish instead of format int value - $format = (int)$candidate->reference; - if ($format < 0 or $format > 4) { - $format = FORMAT_MOODLE; - } - page_20_migrate_candidate($candidate, $fs, $format); + $candidates = $DB->get_recordset('resource_old', array('type'=>'text', 'migrated'=>0)); + foreach ($candidates as $candidate) { + //there might be some rubbish instead of format int value + $format = (int)$candidate->reference; + if ($format < 0 or $format > 4) { + $format = FORMAT_MOODLE; } - $candidates->close(); + page_20_migrate_candidate($candidate, $fs, $format); } + $candidates->close(); // clear all course modinfo caches rebuild_course_cache(0, true); diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index a3078e5c6ec..0030c2a0bd6 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -604,7 +604,8 @@ function quiz_upgrade_grades() { $sql = "SELECT a.*, cm.idnumber AS cmidnumber, a.course AS courseid FROM {quiz} a, {course_modules} cm, {modules} m WHERE m.name='quiz' AND m.id=cm.module AND cm.instance=a.id"; - if ($rs = $DB->get_recordset_sql($sql)) { + $rs = $DB->get_recordset_sql($sql); + if ($rs->valid()) { $pbar = new progress_bar('quizupgradegrades', 500, true); $i=0; foreach ($rs as $quiz) { @@ -613,8 +614,8 @@ function quiz_upgrade_grades() { quiz_update_grades($quiz, 0, false); $pbar->update($i, $count, "Updating Quiz grades ($i/$count)."); } - $rs->close(); } + $rs->close(); } /**