From: Eloy Lafuente (stronk7) Date: Tue, 7 Aug 2018 13:51:34 +0000 (+0200) Subject: Merge branch 'MDL-62065-master' of git://github.com/cescobedo/moodle X-Git-Tag: v3.6.0-beta~525 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=925d1dc60e8d2a4c54ecf7e8d7e7fdd2d9a3f3d3 Merge branch 'MDL-62065-master' of git://github.com/cescobedo/moodle --- 925d1dc60e8d2a4c54ecf7e8d7e7fdd2d9a3f3d3 diff --cc lib/deprecatedlib.php index 9f800cab820,df8c6ad508d..4b13b9ba1b0 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@@ -3288,135 -6614,33 +3288,166 @@@ function groups_get_all_groups_for_cour return $groups; } +/** + * Gets the capabilities that have been cached in the database for this + * component. + * @deprecated since Moodle 3.6. Please use the Events 2 API. + * @todo final deprecation. To be removed in Moodle 4.0 + * + * @access protected To be used from eventslib only + * + * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results' + * @return array of events + */ +function events_get_cached($component) { + global $DB; + + debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.', + DEBUG_DEVELOPER); + + $cachedhandlers = array(); + + if ($storedhandlers = $DB->get_records('events_handlers', array('component'=>$component))) { + foreach ($storedhandlers as $handler) { + $cachedhandlers[$handler->eventname] = array ( + 'id' => $handler->id, + 'handlerfile' => $handler->handlerfile, + 'handlerfunction' => $handler->handlerfunction, + 'schedule' => $handler->schedule, + 'internal' => $handler->internal); + } + } + + return $cachedhandlers; +} + +/** + * Remove all event handlers and queued events + * @deprecated since Moodle 3.6. Please use the Events 2 API. + * @todo final deprecation. To be removed in Moodle 4.0 + * + * @category event + * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results' + */ +function events_uninstall($component) { + debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.', + DEBUG_DEVELOPER); + $cachedhandlers = events_get_cached($component); + events_cleanup($component, $cachedhandlers); + + events_get_handlers('reset'); +} + +/** + * Deletes cached events that are no longer needed by the component. + * @deprecated since Moodle 3.6. Please use the Events 2 API. + * @todo final deprecation. To be removed in Moodle 4.0 + * + * @access protected To be used from eventslib only + * + * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results' + * @param array $cachedhandlers array of the cached events definitions that will be + * @return int number of unused handlers that have been removed + */ +function events_cleanup($component, $cachedhandlers) { + global $DB; + debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.', + DEBUG_DEVELOPER); + $deletecount = 0; + foreach ($cachedhandlers as $eventname => $cachedhandler) { + if ($qhandlers = $DB->get_records('events_queue_handlers', array('handlerid'=>$cachedhandler['id']))) { + //debugging("Removing pending events from queue before deleting of event handler: $component - $eventname"); + foreach ($qhandlers as $qhandler) { + events_dequeue($qhandler); + } + } + $DB->delete_records('events_handlers', array('eventname'=>$eventname, 'component'=>$component)); + $deletecount++; + } + + return $deletecount; +} + +/** + * Removes this queued handler from the events_queued_handler table + * + * Removes events_queue record from events_queue if no more references to this event object exists + * @deprecated since Moodle 3.6. Please use the Events 2 API. + * @todo final deprecation. To be removed in Moodle 4.0 + * + * @access protected To be used from eventslib only + * + * @param stdClass $qhandler A row from the events_queued_handler table + */ +function events_dequeue($qhandler) { + global $DB; + debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.', + DEBUG_DEVELOPER); + // first delete the queue handler + $DB->delete_records('events_queue_handlers', array('id'=>$qhandler->id)); + + // if no more queued handler is pointing to the same event - delete the event too + if (!$DB->record_exists('events_queue_handlers', array('queuedeventid'=>$qhandler->queuedeventid))) { + $DB->delete_records('events_queue', array('id'=>$qhandler->queuedeventid)); + } +} + +/** + * Returns handlers for given event. Uses caching for better perf. + * @deprecated since Moodle 3.6. Please use the Events 2 API. + * @todo final deprecation. To be removed in Moodle 4.0 + * + * @access protected To be used from eventslib only + * + * @staticvar array $handlers + * @param string $eventname name of event or 'reset' + * @return array|false array of handlers or false otherwise + */ +function events_get_handlers($eventname) { + global $DB; + static $handlers = array(); + debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.', + DEBUG_DEVELOPER); + + if ($eventname === 'reset') { + $handlers = array(); + return false; + } + + if (!array_key_exists($eventname, $handlers)) { + $handlers[$eventname] = $DB->get_records('events_handlers', array('eventname'=>$eventname)); + } + + return $handlers[$eventname]; +} ++ + /** + * This function finds the roles assigned directly to this context only + * i.e. no roles in parent contexts + * + * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context(). + * @todo final deprecation. To be removed in Moodle 4.0 + * @param context $context + * @return array + */ + function get_roles_on_exact_context(context $context) { + debugging('get_roles_on_exact_context() is deprecated, please use get_roles_used_in_context() instead.', + DEBUG_DEVELOPER); + + return get_roles_used_in_context($context, false); + } + + /** + * Find out which roles has assignment on this context + * + * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context(). + * @todo final deprecation. To be removed in Moodle 4.0 + * @param context $context + * @return array + */ + function get_roles_with_assignment_on_context(context $context) { + debugging('get_roles_with_assignment_on_context() is deprecated, please use get_roles_used_in_context() instead.', + DEBUG_DEVELOPER); + + return get_roles_used_in_context($context, false); + } diff --cc lib/upgrade.txt index f560ab4b034,1c59166cc2a..7130f018077 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@@ -55,23 -22,9 +55,26 @@@ information provided here is intended e - I set the field "" to multiline - I follow """ in the open menu * Removed the lib/password_compat/lib/password.php file. +* The eventslib.php file has been deleted and its functions have been moved to deprecatedlib.php. The affected functions are: + - events_get_cached() + - events_uninstall() + - events_cleanup() + - events_dequeue() + - events_get_handlers() +* coursecat::get() now has optional $user parameter. +* coursecat::is_uservisible() now has optional $user parameter. +* Removed the lib/form/submitlink.php element which was deprecated in 3.2. +* The user_selector classes do not support custom list of extra identity fields any more. They obey the configured user + policy and respect the privacy setting made by site administrators. The list of user identifiers should never be + hard-coded. Instead, the setting $CFG->showuseridentity should be always respected, which has always been the default + behaviour (MDL-59847). +* The function message_send() in messagelib.php will now only take the object \core\message\message as a parameter. +* The method message_sent::create_from_ids() parameter courseid is now required. A debugging + message was previously displayed, and the SITEID was used, when not provided. +* The method \core\message\manager::send_message() now only takes the object \core\message\message as the first parameter. + * Following functions have been deprecated, please use get_roles_used_in_context. + - get_roles_on_exact_context() + - get_roles_with_assignment_on_context() === 3.5 ===