Merge branch 'MDL-40406-master' of git://github.com/FMCorz/moodle
Conflicts: lib/upgrade.txt
This commit is contained in:
@@ -7230,54 +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.
|
||||
/**
|
||||
* Precreates all contexts including all parents
|
||||
*
|
||||
* @deprecated since 2.2
|
||||
* @param int $contextlevel empty means all
|
||||
* @param bool $buildpaths update paths and depths
|
||||
* @return void
|
||||
*/
|
||||
function create_contexts($contextlevel = null, $buildpaths = true) {
|
||||
context_helper::create_instances($contextlevel, $buildpaths);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove stale context records
|
||||
*
|
||||
* @deprecated since 2.2, use context_helper::cleanup_instances() instead
|
||||
* @return bool
|
||||
*/
|
||||
function cleanup_contexts() {
|
||||
context_helper::cleanup_instances();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate context.path and context.depth where missing.
|
||||
*
|
||||
* @deprecated since 2.2, use context_helper::build_all_paths() instead
|
||||
* @param bool $force force a complete rebuild of the path and depth fields, defaults to false
|
||||
* @return void
|
||||
*/
|
||||
function build_context_path($force = false) {
|
||||
context_helper::build_all_paths($force);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -4986,3 +4986,59 @@ function get_child_contexts(context $context) {
|
||||
debugging('get_child_contexts() is deprecated, please use $context->get_child_contexts() instead.', DEBUG_DEVELOPER);
|
||||
return $context->get_child_contexts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Precreates all contexts including all parents.
|
||||
*
|
||||
* @see context_helper::create_instances()
|
||||
* @deprecated since 2.2
|
||||
* @param int $contextlevel empty means all
|
||||
* @param bool $buildpaths update paths and depths
|
||||
* @return void
|
||||
*/
|
||||
function create_contexts($contextlevel = null, $buildpaths = true) {
|
||||
debugging('create_contexts() is deprecated, please use context_helper::create_instances() instead.', DEBUG_DEVELOPER);
|
||||
context_helper::create_instances($contextlevel, $buildpaths);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove stale context records.
|
||||
*
|
||||
* @see context_helper::cleanup_instances()
|
||||
* @deprecated since 2.2
|
||||
* @return bool
|
||||
*/
|
||||
function cleanup_contexts() {
|
||||
debugging('cleanup_contexts() is deprecated, please use context_helper::cleanup_instances() instead.', DEBUG_DEVELOPER);
|
||||
context_helper::cleanup_instances();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate context.path and context.depth where missing.
|
||||
*
|
||||
* @see context_helper::build_all_paths()
|
||||
* @deprecated since 2.2
|
||||
* @param bool $force force a complete rebuild of the path and depth fields, defaults to false
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -2292,7 +2292,6 @@ class accesslib_testcase extends advanced_testcase {
|
||||
$this->assertEquals($DB->count_records('context', array('depth'=>0)), 0);
|
||||
$this->assertEquals($DB->count_records('context', array('path'=>NULL)), 0);
|
||||
|
||||
|
||||
// ======= context_helper::cleanup_instances() ==========================
|
||||
|
||||
$lastcourse = $DB->get_field_sql("SELECT MAX(id) FROM {course}");
|
||||
@@ -2385,10 +2384,12 @@ class accesslib_testcase extends advanced_testcase {
|
||||
|
||||
$DB->delete_records('context', array('contextlevel'=>CONTEXT_BLOCK));
|
||||
create_contexts();
|
||||
$this->assertDebuggingCalled('create_contexts() is deprecated, please use context_helper::create_instances() instead.', DEBUG_DEVELOPER);
|
||||
$this->assertFalse($DB->record_exists('context', array('contextlevel'=>CONTEXT_BLOCK)));
|
||||
|
||||
$DB->set_field('context', 'depth', 0, array('contextlevel'=>CONTEXT_BLOCK));
|
||||
build_context_path();
|
||||
$this->assertDebuggingCalled('build_context_path() is deprecated, please use context_helper::build_all_paths() instead.', DEBUG_DEVELOPER);
|
||||
$this->assertFalse($DB->record_exists('context', array('depth'=>0)));
|
||||
|
||||
$lastcourse = $DB->get_field_sql("SELECT MAX(id) FROM {course}");
|
||||
@@ -2400,6 +2401,7 @@ class accesslib_testcase extends advanced_testcase {
|
||||
$DB->delete_records('block_instances', array('parentcontextid'=>$frontpagepagecontext->id));
|
||||
$DB->delete_records('course_modules', array('id'=>$frontpagepagecontext->instanceid));
|
||||
cleanup_contexts();
|
||||
$this->assertDebuggingCalled('cleanup_contexts() is deprecated, please use context_helper::cleanup_instances() instead.', DEBUG_DEVELOPER);
|
||||
$count = 1; //system
|
||||
$count += $DB->count_records('user', array('deleted'=>0));
|
||||
$count += $DB->count_records('course_categories');
|
||||
@@ -2408,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)),
|
||||
|
||||
@@ -12,6 +12,10 @@ information provided here is intended especially for developers.
|
||||
* get_parent_contexts() is deprecated, please use $context->get_parent_context_ids().
|
||||
* get_parent_contextid() is deprecated, please use $context->get_parent_context().
|
||||
* get_child_contexts() is deprecated, please use $context->get_child_contexts().
|
||||
* 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().
|
||||
* Use new function moodleform::mock_submit() to simulate form submission in unit tests (backported).
|
||||
|
||||
=== 2.5.1 ===
|
||||
|
||||
Reference in New Issue
Block a user