Skip to content

Commit

Permalink
Merge branch 'wip-MDL-40426-master' of git://github.com/abgreeve/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Jul 16, 2013
2 parents 8eb3e1f + 1de02d6 commit 792e605
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion course/lib.php
Expand Up @@ -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);
Expand Down
33 changes: 0 additions & 33 deletions lib/accesslib.php
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions lib/deprecatedlib.php
Expand Up @@ -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()
}
}
}
}
4 changes: 2 additions & 2 deletions lib/moodlelib.php
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions lib/tests/accesslib_test.php
Expand Up @@ -2442,6 +2442,7 @@ public function test_permission_evaluation() {
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]));

Expand Down
1 change: 1 addition & 0 deletions lib/upgrade.txt
Expand Up @@ -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 ===

Expand Down

0 comments on commit 792e605

Please sign in to comment.