Merge branch 'wip-MDL-40426-master' of git://github.com/abgreeve/moodle

This commit is contained in:
Marina Glancy
2013-07-16 13:48:27 +10:00
6 changed files with 40 additions and 36 deletions
+1 -1
View File
@@ -2275,7 +2275,7 @@ function create_course($data, $editoroptions = NULL) {
cache_helper::purge_by_event('changesincourse');
// new context created - better mark it as dirty
mark_context_dirty($context->path);
$context->mark_dirty();
// Save any custom role names.
save_local_role_names($course->id, (array)$data);
-33
View File
@@ -7247,39 +7247,6 @@ function context_instance_preload_sql($joinon, $contextlevel, $tablealias) {
return array($select, $join);
}
/**
* Mark a context as dirty (with timestamp) so as to force reloading of the context.
*
* @deprecated since 2.2, use $context->mark_dirty() instead
* @param string $path context path
*/
function mark_context_dirty($path) {
global $CFG, $USER, $ACCESSLIB_PRIVATE;
if (during_initial_install()) {
return;
}
// only if it is a non-empty string
if (is_string($path) && $path !== '') {
set_cache_flag('accesslib/dirtycontexts', $path, 1, time()+$CFG->sessiontimeout);
if (isset($ACCESSLIB_PRIVATE->dirtycontexts)) {
$ACCESSLIB_PRIVATE->dirtycontexts[$path] = 1;
} else {
if (CLI_SCRIPT) {
$ACCESSLIB_PRIVATE->dirtycontexts = array($path => 1);
} else {
if (isset($USER->access['time'])) {
$ACCESSLIB_PRIVATE->dirtycontexts = get_cache_flags('accesslib/dirtycontexts', $USER->access['time']-2);
} else {
$ACCESSLIB_PRIVATE->dirtycontexts = array($path => 1);
}
// flags not loaded yet, it will be done later in $context->reload_if_dirty()
}
}
}
}
/**
* Remove a context record and any dependent entries,
* removes context from static context cache too
+35
View File
@@ -4076,3 +4076,38 @@ function print_context_name(context $context, $withprefix = true, $short = false
debugging('print_context_name() is deprecated, please use $context->get_context_name() instead.', DEBUG_DEVELOPER);
return $context->get_context_name($withprefix, $short);
}
/**
* Mark a context as dirty (with timestamp) so as to force reloading of the context.
*
* @deprecated since 2.2, use $context->mark_dirty() instead
* @see context::mark_dirty()
* @param string $path context path
*/
function mark_context_dirty($path) {
global $CFG, $USER, $ACCESSLIB_PRIVATE;
debugging('mark_context_dirty() is deprecated, please use $context->mark_dirty() instead.', DEBUG_DEVELOPER);
if (during_initial_install()) {
return;
}
// only if it is a non-empty string
if (is_string($path) && $path !== '') {
set_cache_flag('accesslib/dirtycontexts', $path, 1, time()+$CFG->sessiontimeout);
if (isset($ACCESSLIB_PRIVATE->dirtycontexts)) {
$ACCESSLIB_PRIVATE->dirtycontexts[$path] = 1;
} else {
if (CLI_SCRIPT) {
$ACCESSLIB_PRIVATE->dirtycontexts = array($path => 1);
} else {
if (isset($USER->access['time'])) {
$ACCESSLIB_PRIVATE->dirtycontexts = get_cache_flags('accesslib/dirtycontexts', $USER->access['time']-2);
} else {
$ACCESSLIB_PRIVATE->dirtycontexts = array($path => 1);
}
// flags not loaded yet, it will be done later in $context->reload_if_dirty()
}
}
}
}
+2 -2
View File
@@ -5237,7 +5237,7 @@ function reset_course_userdata($data) {
}
$DB->delete_records('role_capabilities', array('contextid'=>$context->id));
//force refresh for logged in users
mark_context_dirty($context->path);
$context->mark_dirty();
$status[] = array('component'=>$componentstr, 'item'=>get_string('deletecourseoverrides', 'role'), 'error'=>false);
}
@@ -5247,7 +5247,7 @@ function reset_course_userdata($data) {
role_unassign_all(array('contextid'=>$child->id));
}
//force refresh for logged in users
mark_context_dirty($context->path);
$context->mark_dirty();
$status[] = array('component'=>$componentstr, 'item'=>get_string('deletelocalroles', 'role'), 'error'=>false);
}
+1
View File
@@ -2442,6 +2442,7 @@ class accesslib_testcase extends advanced_testcase {
accesslib_clear_all_caches(true);
$DB->delete_records('cache_flags', array());
mark_context_dirty($systemcontext->path);
$this->assertDebuggingCalled('mark_context_dirty() is deprecated, please use $context->mark_dirty() instead.', DEBUG_DEVELOPER);
$dirty = get_cache_flags('accesslib/dirtycontexts', time()-2);
$this->assertTrue(isset($dirty[$systemcontext->path]));
+1
View File
@@ -22,6 +22,7 @@ information provided here is intended especially for developers.
* context_instance_preload() is deprecated, please use context_helper::preload_from_record().
* get_contextlevel_name() is deprecated, please use context_helper::get_level_name().
* print_context_name() is deprecated, please use $context->get_context_name().
* mark_context_dirty() is deprecated, please use $context->mark_dirty().
=== 2.5.1 ===