MDL-40406 libraries: Deprecate rebuild_contexts()
This commit is contained in:
@@ -7230,20 +7230,6 @@ class context_block extends context {
|
||||
// before removing devs will be warned with a debugging message first,
|
||||
// then we will add error message and only after that we can remove the functions
|
||||
// completely.
|
||||
/**
|
||||
* Rebuild all related context depth and path caches
|
||||
*
|
||||
* @deprecated since 2.2
|
||||
* @param array $fixcontexts array of contexts, strongtyped
|
||||
* @return void
|
||||
*/
|
||||
function rebuild_contexts(array $fixcontexts) {
|
||||
foreach ($fixcontexts as $fixcontext) {
|
||||
$fixcontext->reset_paths(false);
|
||||
}
|
||||
context_helper::build_all_paths(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preloads all contexts relating to a course: course, modules. Block contexts
|
||||
* are no longer loaded here. The contexts for all the blocks on the current
|
||||
|
||||
@@ -5026,3 +5026,19 @@ function build_context_path($force = false) {
|
||||
debugging('build_context_path() is deprecated, please use context_helper::build_all_paths() instead.', DEBUG_DEVELOPER);
|
||||
context_helper::build_all_paths($force);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild all related context depth and path caches.
|
||||
*
|
||||
* @see context::reset_paths()
|
||||
* @deprecated since 2.2
|
||||
* @param array $fixcontexts array of contexts, strongtyped
|
||||
* @return void
|
||||
*/
|
||||
function rebuild_contexts(array $fixcontexts) {
|
||||
debugging('rebuild_contexts() is deprecated, please use $context->reset_paths(true) instead.', DEBUG_DEVELOPER);
|
||||
foreach ($fixcontexts as $fixcontext) {
|
||||
$fixcontext->reset_paths(false);
|
||||
}
|
||||
context_helper::build_all_paths(false);
|
||||
}
|
||||
|
||||
@@ -2410,6 +2410,16 @@ class accesslib_testcase extends advanced_testcase {
|
||||
$count += $DB->count_records('block_instances');
|
||||
$this->assertEquals($DB->count_records('context'), $count);
|
||||
|
||||
// Test legacy rebuild_contexts().
|
||||
$context = context_course::instance($testcourses[2]);
|
||||
rebuild_contexts(array($context));
|
||||
$this->assertDebuggingCalled('rebuild_contexts() is deprecated, please use $context->reset_paths(true) instead.', DEBUG_DEVELOPER);
|
||||
$context = context_course::instance($testcourses[2]);
|
||||
$this->assertEquals($DB->get_field('context', 'path', array('id' => $context->id)), $context->path);
|
||||
$this->assertEquals($DB->get_field('context', 'depth', array('id' => $context->id)), $context->depth);
|
||||
$this->assertEquals(0, $DB->count_records('context', array('depth' => 0)));
|
||||
$this->assertEquals(0, $DB->count_records('context', array('path' => null)));
|
||||
|
||||
context_helper::reset_caches();
|
||||
preload_course_contexts($SITE->id);
|
||||
$this->assertEquals(1 + $DB->count_records('course_modules', array('course' => $SITE->id)),
|
||||
|
||||
@@ -15,6 +15,7 @@ information provided here is intended especially for developers.
|
||||
* create_contexts() is deprecated, please use context_helper::create_instances().
|
||||
* cleanup_contexts() is deprecated, please use context_helper::cleanup_instances().
|
||||
* build_context_path() is deprecated, please use context_helper::build_all_paths().
|
||||
* rebuild_contexts() is deprecated, please use $context->reset_paths().
|
||||
|
||||
=== 2.5.1 ===
|
||||
|
||||
|
||||
Reference in New Issue
Block a user