From c5dcd25d5f4dd79d609776f9ee0a3ab02ab0778f Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Fri, 5 Jul 2013 11:19:46 +0800 Subject: [PATCH] MDL-40425 libraries: Deprecate context_instance_preload() --- lib/accesslib.php | 12 ------------ lib/deprecatedlib.php | 16 +++++++++++++++- lib/tests/accesslib_test.php | 2 ++ lib/upgrade.txt | 1 + 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/accesslib.php b/lib/accesslib.php index 28ddcb9062f..545a61b8e5a 100644 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -7246,18 +7246,6 @@ function context_instance_preload_sql($joinon, $contextlevel, $tablealias) { return array($select, $join); } -/** - * Preloads context information from db record and strips the cached info. - * The db request has to contain both the $join and $select from context_instance_preload_sql() - * - * @deprecated since 2.2 - * @param stdClass $rec - * @return void (modifies $rec) - */ -function context_instance_preload(stdClass $rec) { - context_helper::preload_from_record($rec); -} - /** * Mark a context as dirty (with timestamp) so as to force reloading of the context. * diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 884c8095797..b811ab89cb1 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -5078,4 +5078,18 @@ function preload_course_contexts($courseid) { function context_moved(context $context, context $newparent) { debugging('context_moved() is deprecated, please use context::update_moved() instead.', DEBUG_DEVELOPER); $context->update_moved($newparent); -} \ No newline at end of file +} + +/** + * Preloads context information from db record and strips the cached info. + * The db request has to contain both the $join and $select from context_instance_preload_sql() + * + * @deprecated since 2.2 + * @see context_helper::preload_from_record() + * @param stdClass $rec + * @return void (modifies $rec) + */ +function context_instance_preload(stdClass $rec) { + debugging('context_instance_preload() is deprecated, please use context_helper::preload_from_record() instead.', DEBUG_DEVELOPER); + context_helper::preload_from_record($rec); +} diff --git a/lib/tests/accesslib_test.php b/lib/tests/accesslib_test.php index a6cec468376..86281edef84 100644 --- a/lib/tests/accesslib_test.php +++ b/lib/tests/accesslib_test.php @@ -2432,6 +2432,8 @@ class accesslib_testcase extends advanced_testcase { $records = $DB->get_records_sql($sql); foreach ($records as $record) { context_instance_preload($record); + $this->assertDebuggingCalled('context_instance_preload() is deprecated, please use context_helper::preload_from_record() instead.', + DEBUG_DEVELOPER); $record = (array)$record; $this->assertEquals(1, count($record)); // only id left } diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 74cf9d2e94a..41548ba132b 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -18,6 +18,7 @@ information provided here is intended especially for developers. * rebuild_contexts() is deprecated, please use $context->reset_paths(). * preload_course_contexts() is deprecated, please use context_helper::preload_course(). * context_moved() is deprecated, please use context::update_moved(). +* context_instance_preload() is deprecated, please use context_helper::preload_from_record(). === 2.5.1 ===