MDL-41436 Removing references to fields course.modinfo, sectioncache
Also add the field cacherev to the lists of default fields in course retrieval functions
This commit is contained in:
+12
-14
@@ -43,14 +43,13 @@
|
||||
SET visibleold=visible, visible=0
|
||||
WHERE module=?";
|
||||
$DB->execute($sql, array($module->id));
|
||||
// clear the course modinfo cache for courses
|
||||
// where we just uninstalld something
|
||||
$sql = "UPDATE {course}
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
// Increment course.cacherev for courses where we just made something invisible.
|
||||
// This will force cache rebuilding on the next request.
|
||||
increment_revision_number('course', 'cacherev',
|
||||
"id IN (SELECT DISTINCT course
|
||||
FROM {course_modules}
|
||||
WHERE visibleold=1 AND module=?)";
|
||||
$DB->execute($sql, array($module->id));
|
||||
WHERE visibleold=1 AND module=?)",
|
||||
array($module->id));
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
@@ -60,14 +59,13 @@
|
||||
}
|
||||
$DB->set_field("modules", "visible", "1", array("id"=>$module->id)); // Show main module
|
||||
$DB->set_field('course_modules', 'visible', '1', array('visibleold'=>1, 'module'=>$module->id)); // Get the previous saved visible state for the course module.
|
||||
// clear the course modinfo cache for courses
|
||||
// where we just made something visible
|
||||
$sql = "UPDATE {course}
|
||||
SET modinfo = ''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
// Increment course.cacherev for courses where we just made something visible.
|
||||
// This will force cache rebuilding on the next request.
|
||||
increment_revision_number('course', 'cacherev',
|
||||
"id IN (SELECT DISTINCT course
|
||||
FROM {course_modules}
|
||||
WHERE visible=1 AND module=?)";
|
||||
$DB->execute($sql, array($module->id));
|
||||
WHERE visible=1 AND module=?)",
|
||||
array($module->id));
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ function block_course_overview_get_sorted_courses() {
|
||||
|
||||
$limit = block_course_overview_get_max_user_courses();
|
||||
|
||||
$courses = enrol_get_my_courses('id, shortname, fullname, modinfo, sectioncache');
|
||||
$courses = enrol_get_my_courses();
|
||||
$site = get_site();
|
||||
|
||||
if (array_key_exists($site->id,$courses)) {
|
||||
|
||||
@@ -73,7 +73,6 @@ class block_site_main_menu extends block_list {
|
||||
$strcancel= get_string('cancel');
|
||||
$stractivityclipboard = $USER->activitycopyname;
|
||||
}
|
||||
// Casting $course->modinfo to string prevents one notice when the field is null.
|
||||
$editbuttons = '';
|
||||
|
||||
if ($ismoving) {
|
||||
|
||||
@@ -75,7 +75,6 @@ class block_social_activities extends block_list {
|
||||
$strcancel= get_string('cancel');
|
||||
$stractivityclipboard = $USER->activitycopyname;
|
||||
}
|
||||
// Casting $course->modinfo to string prevents one notice when the field is null.
|
||||
$editbuttons = '';
|
||||
|
||||
if ($ismoving) {
|
||||
|
||||
@@ -684,7 +684,6 @@ class dndupload_ajax_processor {
|
||||
$DB->set_field('course_modules', 'instance', $instanceid, array('id' => $this->cm->id));
|
||||
// Rebuild the course cache after update action
|
||||
rebuild_course_cache($this->course->id, true);
|
||||
$this->course->modinfo = null; // Otherwise we will just get the old version back again.
|
||||
|
||||
$sectionid = course_add_cm_to_section($this->course, $this->cm->id, $this->section);
|
||||
|
||||
|
||||
@@ -641,7 +641,7 @@ class core_course_courselib_testcase extends advanced_testcase {
|
||||
'numsections' => 5),
|
||||
array('createsections' => true));
|
||||
|
||||
// Ensure all 6 (0-5) sections were created and modinfo/sectioninfo cache works properly
|
||||
// Ensure all 6 (0-5) sections were created and course content cache works properly
|
||||
$sectionscreated = array_keys(get_fast_modinfo($course)->get_section_info_all());
|
||||
$this->assertEquals(range(0, $course->numsections), $sectionscreated);
|
||||
|
||||
@@ -731,13 +731,14 @@ class core_course_courselib_testcase extends advanced_testcase {
|
||||
$this->assertEquals($cmids[0], $sequence);
|
||||
|
||||
// Add a second, this time using courseid variant of parameters.
|
||||
$coursecacherev = $DB->get_field('course', 'cacherev', array('id' => $course->id));
|
||||
course_add_cm_to_section($course->id, $cmids[1], 1);
|
||||
$sequence = $DB->get_field('course_sections', 'sequence', array('course' => $course->id, 'section' => 1));
|
||||
$this->assertEquals($cmids[0] . ',' . $cmids[1], $sequence);
|
||||
|
||||
// Check modinfo was not rebuilt (important for performance if calling
|
||||
// repeatedly).
|
||||
$this->assertNull($DB->get_field('course', 'modinfo', array('id' => $course->id)));
|
||||
// Check that modinfo cache was reset but not rebuilt (important for performance if calling repeatedly).
|
||||
$this->assertGreaterThan($coursecacherev, $DB->get_field('course', 'cacherev', array('id' => $course->id)));
|
||||
$this->assertEmpty(cache::make('core', 'coursemodinfo')->get($course->id));
|
||||
|
||||
// Add one to section that doesn't exist (this might rebuild modinfo).
|
||||
course_add_cm_to_section($course, $cmids[2], 2);
|
||||
|
||||
@@ -144,9 +144,9 @@ class core_enrollib_testcase extends advanced_testcase {
|
||||
$course = (array)$course;
|
||||
$this->assertEquals($basefields, array_keys($course), '', 0, 10, true);
|
||||
|
||||
$courses = enrol_get_all_users_courses($user2->id, false, 'modinfo');
|
||||
$courses = enrol_get_all_users_courses($user2->id, false, 'timecreated');
|
||||
$course = reset($courses);
|
||||
$this->assertTrue(property_exists($course, 'modinfo'));
|
||||
$this->assertTrue(property_exists($course, 'timecreated'));
|
||||
|
||||
$courses = enrol_get_all_users_courses($user2->id, false, null, 'id DESC');
|
||||
$this->assertEquals(array($course3->id, $course2->id, $course1->id), array_keys($courses));
|
||||
|
||||
+6
-6
@@ -194,13 +194,13 @@ function uninstall_plugin($type, $name) {
|
||||
}
|
||||
}
|
||||
|
||||
// clear course.modinfo for courses that used this module
|
||||
$sql = "UPDATE {course}
|
||||
SET modinfo=''
|
||||
WHERE id IN (SELECT DISTINCT course
|
||||
// Increment course.cacherev for courses that used this module.
|
||||
// This will force cache rebuilding on the next request.
|
||||
increment_revision_number('course', 'cacherev',
|
||||
"id IN (SELECT DISTINCT course
|
||||
FROM {course_modules}
|
||||
WHERE module=?)";
|
||||
$DB->execute($sql, array($module->id));
|
||||
WHERE module=?)",
|
||||
array($module->id));
|
||||
|
||||
// delete all the course module records
|
||||
$DB->delete_records('course_modules', array('module' => $module->id));
|
||||
|
||||
@@ -844,7 +844,7 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
|
||||
$ctxselect = context_helper::get_preload_record_columns_sql('ctx');
|
||||
$fields = array('c.id', 'c.category', 'c.sortorder',
|
||||
'c.shortname', 'c.fullname', 'c.idnumber',
|
||||
'c.startdate', 'c.visible');
|
||||
'c.startdate', 'c.visible', 'c.cacherev');
|
||||
if (!empty($options['summary'])) {
|
||||
$fields[] = 'c.summary';
|
||||
$fields[] = 'c.summaryformat';
|
||||
@@ -2056,8 +2056,6 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
|
||||
* was called with option 'summary'. Otherwise will be retrieved from DB on first request
|
||||
* @property-read string $format Course format. Retrieved from DB on first request
|
||||
* @property-read int $showgrades Retrieved from DB on first request
|
||||
* @property-read string $sectioncache Retrieved from DB on first request
|
||||
* @property-read string $modinfo Retrieved from DB on first request
|
||||
* @property-read int $newsitems Retrieved from DB on first request
|
||||
* @property-read int $startdate
|
||||
* @property-read int $marker Retrieved from DB on first request
|
||||
@@ -2076,6 +2074,7 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
|
||||
* @property-read int $requested Retrieved from DB on first request
|
||||
* @property-read int $enablecompletion Retrieved from DB on first request
|
||||
* @property-read int $completionnotify Retrieved from DB on first request
|
||||
* @property-read int $cacherev
|
||||
*
|
||||
* @package core
|
||||
* @subpackage course
|
||||
|
||||
+1
-2
@@ -810,8 +810,7 @@ function get_courses_search($searchterms, $sort, $page, $recordsperpage, &$total
|
||||
$ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
|
||||
$params['contextlevel'] = CONTEXT_COURSE;
|
||||
|
||||
$fields = array_diff(array_keys($DB->get_columns('course')), array('modinfo', 'sectioncache'));
|
||||
$sql = "SELECT c.".join(',c.',$fields)." $ccselect
|
||||
$sql = "SELECT c.* $ccselect
|
||||
FROM {course} c
|
||||
$ccjoin
|
||||
WHERE $searchcond AND c.id <> ".SITEID."
|
||||
|
||||
+1
-1
@@ -530,7 +530,7 @@ function enrol_get_my_courses($fields = NULL, $sort = 'visible DESC,sortorder AS
|
||||
$basefields = array('id', 'category', 'sortorder',
|
||||
'shortname', 'fullname', 'idnumber',
|
||||
'startdate', 'visible',
|
||||
'groupmode', 'groupmodeforce');
|
||||
'groupmode', 'groupmodeforce', 'cacherev');
|
||||
|
||||
if (empty($fields)) {
|
||||
$fields = $basefields;
|
||||
|
||||
+1
-1
@@ -5046,7 +5046,7 @@ function remove_course_contents($courseid, $showfeedback = true, array $options
|
||||
$oldcourse = new stdClass();
|
||||
$oldcourse->id = $course->id;
|
||||
$oldcourse->summary = '';
|
||||
$oldcourse->modinfo = null;
|
||||
$oldcourse->cacherev = 0;
|
||||
$oldcourse->legacyfiles = 0;
|
||||
$oldcourse->enablecompletion = 0;
|
||||
if (!empty($options['keep_groups_and_groupings'])) {
|
||||
|
||||
Reference in New Issue
Block a user