Permalink
Browse files

Merge branch 'w47_MDL-36719_m24_borkedcachingfront' of git://github.c…

…om/skodak/moodle
  • Loading branch information...
stronk7 committed Nov 20, 2012
2 parents 8205308 + 5689fb0 commit d937f597e7dd908ded76a8a38caec821272a2488
Showing with 24 additions and 7 deletions.
  1. +15 −6 lib/adminlib.php
  2. +9 −1 lib/modinfolib.php
View
@@ -3390,13 +3390,16 @@ public function get_setting() {
public function write_setting($data) {
global $DB, $SITE;
$record = new stdClass();
- $record->id = SITEID;
+ $record->id = $SITE->id;
$record->{$this->name} = ($data == '1' ? 1 : 0);
$record->timemodified = time();
// update $SITE
$SITE->{$this->name} = $data;
course_get_format($SITE)->update_course_format_options($record);
- return ($DB->update_record('course', $record) ? '' : get_string('errorsetting', 'admin'));
+ $DB->update_record('course', $record);
+ // There is something wrong in cache updates somewhere, let's reset everything.
+ format_base::reset_course_cache();
+ return '';
}
}
@@ -3450,13 +3453,16 @@ public function write_setting($data) {
}
$record = new stdClass();
- $record->id = SITEID;
+ $record->id = $SITE->id;
$record->{$this->name} = $data;
$record->timemodified = time();
// update $SITE
$SITE->{$this->name} = $data;
course_get_format($SITE)->update_course_format_options($record);
- return ($DB->update_record('course', $record) ? '' : get_string('dbupdatefailed', 'error'));
+ $DB->update_record('course', $record);
+ // There is something wrong in cache updates somewhere, let's reset everything.
+ format_base::reset_course_cache();
+ return '';
}
}
@@ -3493,12 +3499,15 @@ public function get_setting() {
public function write_setting($data) {
global $DB, $SITE;
$record = new stdClass();
- $record->id = SITEID;
+ $record->id = $SITE->id;
$record->{$this->name} = $data;
$record->timemodified = time();
$SITE->{$this->name} = $data;
course_get_format($SITE)->update_course_format_options($record);
- return ($DB->update_record('course', $record) ? '' : get_string('errorsetting', 'admin'));
+ $DB->update_record('course', $record);
+ // There is something wrong in cache updates somewhere, let's reset everything.
+ format_base::reset_course_cache();
+ return '';
}
/**
View
@@ -1358,7 +1358,7 @@ function get_fast_modinfo($courseorid, $userid = 0, $resetonly = false) {
* @param boolean $clearonly - only clear the modinfo fields, gets rebuild automatically on the fly
*/
function rebuild_course_cache($courseid=0, $clearonly=false) {
- global $COURSE, $DB, $CFG;
+ global $COURSE, $SITE, $DB, $CFG;
// Destroy navigation caches
navigation_cache::destroy_volatile_caches();
@@ -1382,6 +1382,10 @@ function rebuild_course_cache($courseid=0, $clearonly=false) {
$COURSE->modinfo = null;
$COURSE->sectioncache = null;
}
+ if ($courseid == $SITE->id) {
+ $SITE->modinfo = null;
+ $SITE->sectioncache = null;
+ }
// reset the fast modinfo cache
get_fast_modinfo($courseid, 0, true);
return;
@@ -1408,6 +1412,10 @@ function rebuild_course_cache($courseid=0, $clearonly=false) {
$COURSE->modinfo = $modinfo;
$COURSE->sectioncache = $sectioncache;
}
+ if ($course->id == $SITE->id) {
+ $SITE->modinfo = $modinfo;
+ $SITE->sectioncache = $sectioncache;
+ }
}
$rs->close();
// reset the fast modinfo cache

0 comments on commit d937f59

Please sign in to comment.