MDL-19776 make sure contexts are fully initialised after each core upgrade, it is relatively cheap, so it should not cause any problems
This commit is contained in:
+1
-21
@@ -2008,26 +2008,6 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
upgrade_main_savepoint(true, 2009071000);
|
||||
}
|
||||
|
||||
if ($oldversion < 2009071300) {
|
||||
|
||||
/// Create contexts for every block. In the past, only non-sticky course block had contexts.
|
||||
/// This is a copy of the code in create_contexts.
|
||||
$sql = "INSERT INTO {context} (contextlevel, instanceid)
|
||||
SELECT " . CONTEXT_BLOCK . ", bi.id
|
||||
FROM {block_instances} bi
|
||||
WHERE NOT EXISTS (SELECT 'x'
|
||||
FROM {context} ctx
|
||||
WHERE bi.id = ctx.instanceid AND ctx.contextlevel=" . CONTEXT_BLOCK . ")";
|
||||
$DB->execute($sql);
|
||||
|
||||
/// TODO MDL-19776 We should not really use API functions in upgrade.
|
||||
/// If MDL-19776 is done, we can remove this whole upgrade block.
|
||||
build_context_path();
|
||||
|
||||
/// Main savepoint reached
|
||||
upgrade_main_savepoint(true, 2009071300);
|
||||
}
|
||||
|
||||
if ($oldversion < 2009071600) {
|
||||
|
||||
/// Define field summaryformat to be added to post
|
||||
@@ -2096,7 +2076,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
// The new global navigation block instance as a stdClass
|
||||
$newblockinstances['globalnavigation']->blockname = 'global_navigation_tree';
|
||||
$newblockinstances['globalnavigation']->parentcontextid = $syscontext->id; // System context
|
||||
$newblockinstances['globalnavigation']->showinsubcontexts = true; // Show absolutly everywhere
|
||||
$newblockinstances['globalnavigation']->showinsubcontexts = true; // Show absolutely everywhere
|
||||
$newblockinstances['globalnavigation']->pagetypepattern = '*'; // Thats right everywhere
|
||||
$newblockinstances['globalnavigation']->subpagetypepattern = null;
|
||||
$newblockinstances['globalnavigation']->defaultregion = BLOCK_POS_LEFT;
|
||||
|
||||
@@ -1259,6 +1259,11 @@ function upgrade_core($version, $verbose) {
|
||||
// Reset caches again, just to be sure
|
||||
upgrade_reset_caches();
|
||||
remove_dir($CFG->dataroot . '/cache', true); // flush cache
|
||||
|
||||
// Clean up contexts - more and more stuff depends on existence of paths and contexts
|
||||
cleanup_contexts();
|
||||
create_contexts();
|
||||
build_context_path();
|
||||
$syscontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
mark_context_dirty($syscontext->path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user