From 158cd5d91acdecda8b21655199d2747bfaa58db5 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Tue, 16 Mar 2010 06:59:34 +0000 Subject: [PATCH] rating MDL-21657 Fixed 2 upgrade problems --- lib/db/upgrade.php | 4 +++- lib/db/upgradelib.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index c6dd863e8c7..2368a55b23d 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -3076,7 +3076,9 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); $table->add_index('itemid', XMLDB_INDEX_NOTUNIQUE, array('itemid')); /// Create table for ratings - $dbman->create_table($table); + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } //migrate ratings out of the modules into the central ratings table diff --git a/lib/db/upgradelib.php b/lib/db/upgradelib.php index c46827d13a1..fdfe3355cc6 100644 --- a/lib/db/upgradelib.php +++ b/lib/db/upgradelib.php @@ -411,7 +411,7 @@ function upgrade_module_ratings($ratingssql, $modulename) { upgrade_set_timeout(60);//prevent a timeout } - //all posts within a given forum will have the same context id so store them in an array + //all posts within a given forum, glossary etc will have the same context id so store them in an array if( !array_key_exists($old_rating->mid, $contextarray) ) { $sql = 'select cxt.id from {course_modules} cm inner join {modules} m on cm.module=m.id inner join {context} cxt on cxt.instanceid=cm.id @@ -436,7 +436,7 @@ where m.name=:modulename and cm.instance=:moduleinstanceid and cxt.contextlevel= $result = $result && $DB->insert_record('ratings', $rating); } - $ratings->close(); + //$ratings->close(); return $result; }