// 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
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);
+}
$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)),
* 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 ===