MDL-81044 backup: Coding style fixes

This commit is contained in:
Andrew Nicols 2024-02-26 10:37:47 +08:00
parent 7b63a6864a
commit 275e5f9412
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14

View File

@ -17,20 +17,15 @@
/**
* Utility helper for automated backups run through cron.
*
* This class is an abstract class with methods that can be called to aid the
* running of automated backups over cron.
*
* @package core
* @subpackage backup
* @copyright 2010 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* This class is an abstract class with methods that can be called to aid the
* running of automated backups over cron.
*/
abstract class backup_cron_automated_helper {
/** Automated backups are active and ready to run */
const STATE_OK = 0;
/** Automated backups are disabled and will not be run */
@ -796,13 +791,13 @@ abstract class backup_cron_automated_helper {
*/
protected static function is_course_modified($courseid, $since) {
global $DB;
$logmang = get_log_manager();
$readers = $logmang->get_readers('core\log\sql_reader');
/** @var \core\log\sql_reader[] */
$readers = get_log_manager()->get_readers('core\log\sql_reader');
// Exclude events defined by hook.
$hook = new \core_backup\hook\before_course_modified_check();
\core\hook\manager::get_instance()->dispatch($hook);
$excludedevents = $hook->get_excluded_events();
foreach ($readers as $readerpluginname => $reader) {
$params = [
@ -811,15 +806,14 @@ abstract class backup_cron_automated_helper {
];
$where = "courseid = :courseid and timecreated > :since and crud <> 'r'";
$excludeevents = [];
$excludeevents = $hook->get_excluded_events();
// Prevent logs of previous backups causing a false positive.
if ($readerpluginname != 'logstore_legacy') {
if ($readerpluginname !== 'logstore_legacy') {
$excludeevents[] = '\core\event\course_backup_created';
}
$excludeevents = array_merge($excludeevents, $excludedevents);
if ($excludeevents) {
list($notinsql, $notinparams) = $DB->get_in_or_equal($excludeevents, SQL_PARAMS_NAMED, 'eventname', false);
[$notinsql, $notinparams] = $DB->get_in_or_equal($excludeevents, SQL_PARAMS_NAMED, 'eventname', false);
$where .= 'AND eventname ' . $notinsql;
$params = array_merge($params, $notinparams);
}