Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-38541 Restrict calling rebuild_course_cache() from upgrade process

only plugins upgrade scripts can call rebuild_course_cache() and for clearing cache only.
  • Loading branch information...
commit 69778612db1712657a4383c0db02e2b62248ece7 1 parent bd11908
@marinaglancy marinaglancy authored
Showing with 8 additions and 2 deletions.
  1. +2 −2 lib/db/upgrade.php
  2. +6 −0 lib/modinfolib.php
View
4 lib/db/upgrade.php
@@ -1460,7 +1460,7 @@ function xmldb_main_upgrade($oldversion) {
if ($oldversion < 2012111200.01) {
// Force the rebuild of the cache of every courses, some cached information could contain wrong icon references.
- rebuild_course_cache();
+ $DB->execute('UPDATE {course} set modinfo = ?, sectioncache = ?', array(null, null));
// Main savepoint reached.
upgrade_main_savepoint(true, 2012111200.01);
@@ -1605,7 +1605,7 @@ function xmldb_main_upgrade($oldversion) {
$DB->delete_records('course_sections_avail_fields', array('userfield' => 'interests'));
$DB->delete_records('course_modules_avail_fields', array('userfield' => 'interests'));
// Clear course cache (will be rebuilt on first visit) in case of changes to these.
- rebuild_course_cache(0, true);
+ $DB->execute('UPDATE {course} set modinfo = ?, sectioncache = ?', array(null, null));
upgrade_main_savepoint(true, 2012120301.13);
}
View
6 lib/modinfolib.php
@@ -1360,6 +1360,12 @@ function get_fast_modinfo($courseorid, $userid = 0, $resetonly = false) {
function rebuild_course_cache($courseid=0, $clearonly=false) {
global $COURSE, $SITE, $DB, $CFG;
+ if (!$clearonly && !empty($CFG->upgraderunning)) {
+ debugging('Function rebuild_course_cache() should not be called from upgrade script unless with argument clearonly.',
+ DEBUG_DEVELOPER);
+ $clearonly = true;
+ }
+
// Destroy navigation caches
navigation_cache::destroy_volatile_caches();
Please sign in to comment.
Something went wrong with that request. Please try again.