1 This files describes API changes in core libraries and APIs,
2 information provided here is intended especially for developers.
6 * PHPUnit cannot be installed via PEAR any more, please use composer package manager instead.
7 * $core_renderer->block_move_target() changed to support more verbose move-block-here descriptions.
10 * Significant changes in Logging API. For upgrading existing events_trigger() and
11 add_to_log() see http://docs.moodle.org/dev/Migrating_logging_calls_in_plugins
12 For accessing logs from plugins see http://docs.moodle.org/dev/Migrating_log_access_in_reports
15 * $module uses in mod/xxx/version.php files is now deprecated. Please use $plugin instead. It will be removed in Moodle 2.10.
16 * Update init methods in all event classes - "level" property was renamed to "edulevel", the level property is now deprecated.
17 * Abstract class \core\event\course_module_instances_list_viewed is deprecated now, use \core\event\instances_list_viewed instead.
18 * Abstract class core\event\content_viewed has been deprecated. Please extend base event or other relevant abstract class.
19 * mod_book\event\instances_list_viewed has been deprecated. Please use mod_book\event\course_module_instance_list_viewed instead.
20 * mod_chat\event\instances_list_viewed has been deprecated. Please use mod_chat\event\course_module_instance_list_viewed instead.
21 * mod_choice\event\instances_list_viewed has been deprecated. Please use mod_choice\event\course_module_instance_list_viewed instead.
22 * mod_feedback\event\instances_list_viewed has been deprecated. Please use mod_feedback\event\course_module_instance_list_viewed instead.
23 * mod_page\event\instances_list_viewed has been deprecated. Please use mod_page\event\course_module_instance_list_viewed instead.
24 * The constants FRONTPAGECOURSELIST, FRONTPAGETOPICONLY & FRONTPAGECOURSELIMIT have been removed.
25 * Conditional availability API has moved and changed. The condition_info class is
26 replaced by \core_availability\info_module, and condition_info_section by
27 \core_availability\info_section. (Code that uses the old classes will generally
29 * coursemodule_visible_for_user() has been deprecated but still works - replaced
30 by a new static function \core_availability\info_module::is_user_visible()
31 * cm_info::is_user_access_restricted_by_conditional_access has been deprecated
32 but still works (it has never done what its name suggests, and is
34 * cm_info and section_info property showavailability has been deprecated, but
35 still works (with the caveat that this information is now per-user).
36 * cm_info and section_info properties availablefrom and availableuntil have been
37 deprecated and always return zero (underlying data doesn't have these values).
38 * section_info property groupingid has been deprecated and always returns zero,
40 * Various cm_info methods have been deprecated in favour of their read-only properties (get_url(), get_content(), get_extra_classes(),
41 get_on_click(), get_custom_data(), get_after_link, get_after_edit_icons)
42 * The ajaxenabled function has been deprecated and always returns true. All code should be fully functional in Javascript.
43 * count_login_failures() has been deprecated, use user_count_login_failures() instead. Refer MDL-42891 for details.
45 Conditional availability (activities and sections):
46 * New conditional availability API in /availability, including new availability
47 condition plugins in /availability/condition. The new API is very similar with
48 regard to checking availability, but any code that modifies availability settings
49 for an activity or section is likely to need substantial changes.
52 * The lightbox attribute for moodle-core-notification-dialogue has been
53 deprecated and replaced by the modal attribute. This was actually
54 changed in Moodle 2.2, but has only been marked as deprecated now. It
55 will be removed in Moodle 2.9.
56 * When destroying any type of dialogue based on moodle-core-notification, the relevant content is also removed from
57 the DOM. Previously it was left orphaned.
60 * The findChildNodes global function has been deprecated. Y.all should
62 * The callback argument to confirm_action and M.util.show_confirm_dialog has been deprecated. If you need to write a
63 confirmation which includes a callback, please use moodle-core-notification-confirmation and attach callbacks to the
66 * New locking api and admin settings to configure the system locking type.
67 * New "Time spent waiting for the database" performance metric displayed along with the
68 other MDL_PERF vars; the change affects both the error logs and the vars displayed in
70 * Changes in the tag API. The component and contextid are now saved when assigning tags to an item. Please see
71 tag/upgrade.txt for more information.
75 * Use new methods from core_component class instead of get_core_subsystems(), get_plugin_types(),
76 get_plugin_list(), get_plugin_list_with_class(), get_plugin_directory(), normalize_component(),
77 get_component_directory() and get_plugin_list_with_file(). The names of the new methods are
78 exactly the same, the only differences are that core_component::get_plugin_types() now always returns
79 full paths and core_component::get_plugin_list() does not accept empty parameter any more.
80 * Use core_text::* instead of textlib:: and also core_collator::* instead of collatorlib::*.
81 * Use new function moodleform::mock_submit() to simulate form submission in unit tests (backported).
82 * New $CFG->localcachedir setting useful for cluster nodes. Admins have to update X-Sendfile aliases if used.
83 * MS SQL Server drivers are now using NVARCHAR(MAX) instead of NTEXT and VARBINARY(MAX) instead of IMAGE,
84 this change should be fully transparent and it should help significantly with add-on compatibility.
85 * The string manager classes were renamed. Note that they should not be modified or used directly,
86 always use get_string_manager() to get instance of the string manager.
87 * The ability to use an 'insecure' rc4encrypt/rc4decrypt key has been removed.
88 * Use $CFG->debugdeveloper instead of debugging('', DEBUG_DEVELOPER).
89 * Use set_debugging(DEBUG_xxx) when changing debugging level for current request.
90 * Function moveto_module() does not modify $mod argument and instead now returns the new module visibility value.
91 * Use behat_selectors::get_allowed_text_selectors() and behat_selectors::get_allowed_selectors() instead of
92 behat_command::$allowedtextselectors and behat_command::$allowedselectors
93 * Subplugins are supported in admin tools and local plugins.
94 * file_packer/zip_packer API has been modified so that key functions support a new file_progress interface
95 to report progress during long operations. Related to this, zip_archive now supports an estimated_count()
96 function that returns an approximate number of entries in the zip faster than the count() function.
97 * Class cm_info no longer extends stdClass. All properties are read-only and calculated on first request only.
98 * Class course_modinfo no longer extends stdClass. All properties are read-only.
99 * Database fields modinfo and sectioncache in table course are removed. Application cache core/coursemodinfo
100 is used instead. Course cache is still reset, rebuilt and retrieved using function rebuild_course_cache() and
101 get_fast_modinfo(). Purging all caches and every core upgrade purges course modinfo cache as well.
102 If function get_fast_modinfo() is called for multiple courses make sure to include field cacherev in course
104 * Internal (noreply and support) user support has been added for sending/receiving message.
105 Use core_user::get_noreply_user() and core_user::get_support_user() to get noreply and support user's respectively.
106 Real users can be used as noreply/support users by setting $CFG->noreplyuserid and $CFG->supportuserid
107 * New function readfile_allow_large() in filelib.php for use when very large files may need sending to user.
108 * Use core_plugin_manager::reset_caches() when changing visibility of plugins.
109 * Implement new method get_enabled_plugins() method in subplugin info classes.
110 * Each plugin should include version information in version.php.
111 * Module and block tables do not contain version column any more, use get_config('xx_yy', 'version') instead.
112 * $USER->password field is intentionally unset so that session data does not contain password hashes.
113 * Use core_shutdown_manager::register_function() instead of register_shutdown_function().
114 * New file packer for .tar.gz files; obtain by calling get_file_packer('application/x-gzip'). Intended initially
115 for use in backup/restore only, as there are limitations on supported filenames. Also new packer for
116 backups which supports both compression formats; get_file_packer('application/vnd.moodle.backup').
117 * New optional parameter to stored_file::get_content_file_handle to open file handle with 'gzopen' instead
118 of 'fopen' to read gzip-compressed files if required.
119 * update_internal_user_password() and setnew_password_and_mail() now trigger user_updated event.
120 * Add thirdpartylibs.xml file to plugins that bundle any 3rd party libraries.
121 * New class introduced to help auto generate zIndex values for modal dialogues. Class "moodle-has-zindex"
122 should set on any element which uses a non-default zindex and needs to ensure it doesn't show above a
124 * $CFG->filelifetime is now used consistently for most file serving operations, the default was lowered
125 to 6 hours from 24 hours because etags and x-sendfile support should make file serving less expensive.
126 * Date format locale charset for windows server will come from calendar type and for gregorian it will use
128 * The library to interact with Box.net (class boxclient) is only compatible with their APIv1 which
129 reaches its end of life on the 14th of Dec. You should migrate your scripts to make usage of the
130 new class boxnet_client(). Note that the method names and return values have changed.
131 * Settings pages are now possible for Calendar type plugins. Calendar type plugins that require a settings page to
132 work properly will need to set their requires version to a number that is equal to or grater than the 2.6.1 release version.
133 * The admin/tool/generator tool was overhauled to use testing data generators and the previous interface to create
134 test data was removed (it was not working correctly anyway). If you were using this tool you will probably need to
138 Various previously deprecated functions have now been altered to throw DEBUG_DEVELOPER debugging notices
139 and will be removed in a future release (target: 2.8), a summary follows:
142 * get_context_instance() -> context_xxxx::instance()
143 * get_context_instance_by_id() -> context::instance_by_id($id)
144 * get_system_context() -> context_system::instance()
145 * context_moved() -> context::update_moved()
146 * preload_course_contexts() -> context_helper::preload_course()
147 * context_instance_preload() -> context_helper::preload_from_record()
148 * context_instance_preload_sql() -> context_helper::get_preload_record_columns_sql()
149 * get_contextlevel_name() -> context_helper::get_level_name()
150 * create_contexts() -> context_helper::create_instances()
151 * cleanup_contexts() -> context_helper::cleanup_instances()
152 * build_context_path() -> context_helper::build_all_paths()
153 * print_context_name() -> $context->get_context_name()
154 * mark_context_dirty() -> $context->mark_dirty()
155 * delete_context() -> $context->delete_content() or context_helper::delete_instance()
156 * get_context_url() -> $context->get_url()
157 * get_course_context() -> $context->get_course_context()
158 * get_parent_contexts() -> $context->get_parent_context_ids()
159 * get_parent_contextid() -> $context->get_parent_context()
160 * get_child_contexts() -> $context->get_child_contexts()
161 * rebuild_contexts() -> $context->reset_paths()
162 * get_user_courses_bycap() -> enrol_get_users_courses()
163 * get_courseid_from_context() -> $context->get_course_context(false)
164 * get_role_context_caps() -> (no replacement)
165 * load_temp_role() -> (no replacement)
166 * remove_temp_roles() -> (no replacement)
167 * get_related_contexts_string() -> $context->get_parent_context_ids(true)
168 * get_recent_enrolments() -> (no replacement)
171 * get_course_participants() -> get_enrolled_users()
172 * is_course_participant() -> is_enrolled()
175 * current_theme() -> $PAGE->theme->name
176 * skip_main_destination() -> $OUTPUT->skip_link_target()
177 * print_container() -> $OUTPUT->container()
178 * print_container_start() -> $OUTPUT->container_start()
179 * print_container_end() -> $OUTPUT->container_end()
180 * print_continue() -> $OUTPUT->continue_button()
181 * print_header() -> $PAGE methods
182 * print_header_simple() -> $PAGE methods
183 * print_side_block() -> $OUTPUT->block()
184 * print_arrow() -> $OUTPUT->arrow()
185 * print_scale_menu_helpbutton() -> $OUTPUT->help_icon_scale($courseid, $scale)
186 * print_checkbox() -> html_writer::checkbox()
189 * print_navigation() -> $OUTPUT->navbar()
190 * build_navigation() -> $PAGE->navbar methods
191 * navmenu() -> (no replacement)
192 * settings_navigation::
193 get_course_modules() -> (no replacement)
195 Files and repositories:
196 * stored_file::replace_content_with() -> stored_file::replace_file_with()
197 * stored_file::set_filesize() -> stored_file::replace_file_with()
198 * stored_file::get_referencelifetime() -> (no replacement)
199 * repository::sync_external_file() -> see repository::sync_reference()
200 * repository::get_file_by_reference() -> repository::sync_reference()
202 get_reference_file_lifetime() -> (no replacement)
203 * repository::sync_individual_file() -> (no replacement)
204 * repository::reset_caches() -> (no replacement)
207 * add_event() -> calendar_event::create()
208 * update_event() -> calendar_event->update()
209 * delete_event() -> calendar_event->delete()
210 * hide_event() -> calendar_event->toggle_visibility(false)
211 * show_event() -> calendar_event->toggle_visibility(true)
214 * filter_text() -> format_text(), format_string()...
215 * httpsrequired() -> $PAGE->https_required()
216 * detect_munged_arguments() -> clean_param([...], PARAM_FILE)
217 * mygroupid() -> groups_get_all_groups()
218 * js_minify() -> core_minify::js_files()
219 * css_minify_css() -> core_minify::css_files()
220 * course_modinfo::build_section_cache() -> (no replacement)
221 * generate_email_supportuser() -> core_user::get_support_user()
224 * session_get_instance()->xxx() -> \core\session\manager::xxx()
225 * session_kill_all() -> \core\session\manager::kill_all_sessions()
226 * session_touch() -> \core\session\manager::touch_session()
227 * session_kill() -> \core\session\manager::kill_session()
228 * session_kill_user() -> \core\session\manager::kill_user_sessions()
229 * session_gc() -> \core\session\manager::gc()
230 * session_set_user() -> \core\session\manager::set_user()
231 * session_is_loggedinas() -> \core\session\manager::is_loggedinas()
232 * session_get_realuser() -> \core\session\manager::get_realuser()
233 * session_loginas() -> \core\session\manager::loginas()
235 User-agent related functions:
236 * check_browser_operating_system() -> core_useragent::check_browser_operating_system()
237 * check_browser_version() -> core_useragent::check_browser_version()
238 * get_device_type() -> core_useragent::get_device_type()
239 * get_device_type_list() -> core_useragent::get_device_type_list()
240 * get_selected_theme_for_device_type() -> core_useragent::get_device_type_theme()
241 * get_device_cfg_var_name() -> core_useragent::get_device_type_cfg_var_name()
242 * set_user_device_type() -> core_useragent::set_user_device_type()
243 * get_user_device_type() -> core_useragent::get_user_device_type()
244 * get_browser_version_classes() -> core_useragent::get_browser_version_classes()
247 * moodle-core-notification has been deprecated with a recommendation of
248 using its subclasses instead. This is to allow for reduced page
249 transport costs. Current subclasses include:
256 Event triggering and event handlers:
257 * All existing events and event handlers should be replaced by new
258 event classes and matching new event observers.
259 * See http://docs.moodle.org/dev/Event_2 for more information.
260 * The following events will be entirely removed, though they can still
261 be captured using handlers, but they should not be used any more.
262 * groups_members_removed -> \core\event\group_member_removed
263 * groups_groupings_groups_removed -> (no replacement)
264 * groups_groups_deleted -> \core\event\group_deleted
265 * groups_groupings_deleted -> \core\event\grouping_deleted
266 * edit_module_post_actions() does not trigger events any more.
270 * New get_course() function for use when obtaining the course record from database. Will
271 reuse existing $COURSE or $SITE globals if possible to improve performance.
275 * The database drivers (moodle_database and subclasses) aren't using anymore the ::columns property
276 for caching database metadata. MUC (databasemeta) is used instead. Any custom DB driver should
277 apply for that change.
278 * The cron output has been changed to include time and memory usage (see cron_trace_time_and_memory()),
279 so any custom utility relying on the old output may require modification.
280 * Function get_max_file_sizes now returns an option for (for example) "Course limit (500MB)" or
281 "Site limit (200MB)" when appropriate with the option set to 0. This function no longer returns
282 an option for 0 bytes. Existing code that was replacing the 0 option in the return
283 from this function with a more sensible message, can now use the return from this function directly.
284 * Functions responsible for output in course/lib.php are deprecated, the code is moved to
285 appropriate renderers: print_section(), print_section_add_menus(), get_print_section_cm_text(),
286 make_editing_buttons()
287 See functions' phpdocs in lib/deprecatedlib.php
288 * Function get_print_section_cm_text() is deprecated, replaced with methods in cm_info
289 * zip_packer may create empty zip archives, there is a new option to ignore
290 problematic files when creating archive
291 * The function delete_course_module was deprecated and has been replaced with
292 course_delete_module. The reason for this was because the function delete_course_module
293 only partially deletes data, so wherever it was called extra code was needed to
294 perform the whole deletion process. The function course_delete_module now takes care
295 of the whole process.
296 * curl::setopt() does not accept constant values any more. As it never worked properly,
297 we decided to make the type check stricter. Now, the keys of the array pass must be a string
298 corresponding to the curl constant name.
299 * Function get_users_listing now return list of users except guest and deleted users. Previously
300 deleted users were excluded by get_users_listing. As guest user is not expected while browsing users,
301 and not included in get_user function, it will not be returned by get_users_listing.
302 * The add_* functions in course/dnduploadlib.php have been deprecated. Plugins should be using the
303 MODNAME_dndupload_register callback instead.
304 * The signature of the add() method of classes implementing the parentable_part_of_admin_tree
305 interface (such as admin_category) has been extended. The new parameter allows the caller
306 to prepend the new node before an existing sibling in the admin tree.
307 * condition_info:get_condition_user_fields($formatoptions) now accepts the optional
308 param $formatoptions, that will determine if the field names are processed by
309 format_string() with the passed options.
310 * remove all references to $CFG->gdversion, GD PHP extension is now required
311 * Formslib will now throw a developer warning if a PARAM_ type hasn't been set for elements which
312 need it. Please set PARAM_RAW explicitly if you do not want any cleaning.
313 * Functions responsible for managing and accessing course categories are moved to class coursecat
314 in lib/coursecatlib.php, functions responsible for rendering courses and categories lists are
315 moved to course/renderer.php. The following global functions are deprecated: make_categories_list(),
316 category_delete_move(), category_delete_full(), move_category(), course_category_hide(),
317 course_category_show(), get_course_category(), create_course_category(), get_all_subcategories(),
318 get_child_categories(), get_categories(), print_my_moodle(), print_remote_course(),
319 print_remote_host(), print_whole_category_list(), print_category_info(), get_course_category_tree(),
320 print_courses(), print_course(), get_category_courses_array(), get_category_courses_array_recursively(),
321 get_courses_wmanagers()
322 See http://docs.moodle.org/dev/Courses_lists_upgrade_to_2.5
323 * $core_renderer->block_move_target() changed to support more verbose move-block-here descriptions.
324 * Additional (optional) param $onlyactive has been added to get_enrolled_users, count_enrolled_users
325 functions to get information for only active (excluding suspended enrolments) users. Included two
326 helper functions extract_suspended_users, get_suspended_userids to extract suspended user information.
327 * The core_plugin_manager class now provides two new helper methods for getting information
328 about known plugins: get_plugins_of_type() and get_subplugins_of_plugin().
329 * The get_uninstall_url() method of all subclasses of \core\plugininfo\base class is now expected
330 to always return moodle_url. Subclasses can use the new method is_uninstall_allowed()
331 to control the availability of the 'Uninstall' link at the Plugins overview page (previously
332 they would do it by get_uninstall_url() returning null). By default, URL to a new general plugin
333 uninstall tool is returned. Unless the plugin type needs extra steps that can't be handled by
334 plugininfo_xxx::uninstall() method or xmldb_xxx_uninstall() function, this default URL should
335 satisfy all plugin types.
337 Database (DML) layer:
338 * $DB->sql_empty() is deprecated, you have to use sql parameters with empty values instead,
339 please note hardcoding of empty strings in SQL queries breaks execution in Oracle database.
340 * Indexes must not be defined on the same columns as keys, this is now reported as fatal problem.
341 Please note that internally we create indexes instead of foreign keys.
344 * M.util.help_icon has been deprecated. Code should be updated to use moodle-core-popuphelp
345 instead. To do so, remove any existing JS calls to M.util.help_icon from your PHP and ensure
346 that your help link is placed in a span which has the class 'helplink'.
350 * Pagelib: Numerous deprecated functions were removed as classes page_base, page_course
351 and page_generic_activity.
352 * use $CFG->googlemapkey3 instead of removed $CFG->googlemapkey and migrate to Google Maps API V3
353 * Function settings_navigation::add_course_editing_links() is completely removed
354 * function global_navigation::format_display_course_content() is removed completely (the
355 functionality is moved to course format class)
356 * in the function global_navigation::load_generic_course_sections() the argument $courseformat is
358 * New component and itemid columns in groups_members table - this allows plugin to create protected
359 group memberships using 'xx_yy_allow_group_member_remove' callback and there is also a new restore
360 callback 'xx_yy_restore_group_member()'.
361 * New general role assignment restore plugin callback 'xx_yy_restore_role_assignment()'.
362 * functions get_generic_section_name(), get_all_sections(), add_mod_to_section(), get_all_mods()
363 are deprecated. See their phpdocs in lib/deprecatedlib.php on how to replace them
366 * moodle-enrol-notification has been renamed to moodle-core-notification
367 * YUI2 code must now use 2in3, see http://yuilibrary.com/yui/docs/yui/yui-yui2.html
368 * M.util.init_select_autosubmit() and M.util.init_url_select() have been deprecated. Code using this should be updated
369 to use moodle-core-formautosubmit
371 Unit testing changes:
372 * output debugging() is not sent to standard output any more,
373 use $this->assertDebuggingCalled(), $this->assertDebuggingNotCalled(),
374 $this->getDebuggingMessages() or $this->assertResetDebugging() instead.
378 Database layer changes:
379 * objects are not allowed in paramters of DML functions, use explicit casting to strings if necessary
382 * DDL and DML methods which were deprecated in 2.0 have now been removed, they will no longer produce
383 debug messages and will produce fatal errors
387 * send_stored_file() has changed its interface
388 * deleted several resourcelib_embed_* functions from resourcelib.php
392 removed unused libraries:
393 * odbc, base32, CodeSniffer, overlib, apd profiling, kses, Smarty, PEAR Console, swfobject, cssshover.htc, md5.js
396 * new admin/tool plugin type
397 * new context API - old API is still available
398 * deleted users do not have context any more
399 * removed global search
405 * basic suport for restore from 1.9
406 * new mobile devices API
413 * new DML API - http://docs.moodle.org/dev/DML_functions
414 * new DDL API - http://docs.moodle.org/dev/DDL_functions
415 * new file API - http://docs.moodle.org/dev/File_API
416 * new $PAGE and $OUTPUT API
418 * new theme API - http://docs.moodle.org/dev/Theme_changes_in_2.0
419 * new javascript API - http://docs.moodle.org/dev/JavaScript_usage_guide
421 * new local plugin type
422 * new translation support - http://lang.moodle.org
423 * new web service API
430 * new backup/restore API
433 * improved plugin support (aka Frankenstyle)
434 * new registration and hub API
435 * new course completion API
438 * new text editor API
439 * new my moodle and profiles API