Skip to content

Commit

Permalink
Update for Moodle 4.3 (#190)
Browse files Browse the repository at this point in the history
* CI: Update for Moodle 4.3

* Prevent dynamic property access on classes for PHP 8.2

* phpcbf for styles etc.

---------

Co-authored-by: Justus Dieckmann <[email protected]>
Co-authored-by: NinaHerrmann <[email protected]>
  • Loading branch information
3 people authored Feb 20, 2024
1 parent 38d6dc7 commit 421cc45
Show file tree
Hide file tree
Showing 71 changed files with 341 additions and 332 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:

strategy:
matrix:
php: ['8.1']
moodle-branch: ['MOODLE_402_STABLE']
php: ['8.2']
moodle-branch: ['MOODLE_403_STABLE']
database: ['pgsql']

steps:
Expand Down Expand Up @@ -107,9 +107,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.0', '8.1']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE']
php: ['8.0', '8.1', '8.2']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE']
database: ['mariadb', 'pgsql']
exclude:
- php: '8.2'
moodle-branch: 'MOODLE_401_STABLE'
include:
- php: '7.4'
moodle-branch: 'MOODLE_39_STABLE'
Expand Down
2 changes: 1 addition & 1 deletion activeworkflows.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
'inputname' => 'search',
'extraclasses' => 'mb-3',
'inform' => false,
'searchstring' => 'Search for courses'
'searchstring' => 'Search for courses',
]);

echo $OUTPUT->heading(get_string('active_automatic_workflows_heading', 'tool_lifecycle'));
Expand Down
10 changes: 5 additions & 5 deletions classes/event/process_proceeded.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ class process_proceeded extends \core\event\base {
* @throws \dml_exception
*/
public static function event_from_process($process) {
$data = array(
$data = [
'context' => \context_system::instance(),
'other' => array(
'other' => [
'processid' => $process->id,
'workflowid' => $process->workflowid,
'stepindex' => $process->stepindex,
'courseid' => $process->courseid
)
);
'courseid' => $process->courseid,
],
];
return self::create($data);
}

Expand Down
10 changes: 5 additions & 5 deletions classes/event/process_rollback.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ class process_rollback extends \core\event\base {
* @throws \dml_exception
*/
public static function event_from_process($process) {
$data = array(
$data = [
'context' => \context_system::instance(),
'other' => array(
'other' => [
'processid' => $process->id,
'workflowid' => $process->workflowid,
'stepindex' => $process->stepindex,
'courseid' => $process->courseid
)
);
'courseid' => $process->courseid,
],
];
return self::create($data);
}

Expand Down
10 changes: 5 additions & 5 deletions classes/event/process_triggered.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class process_triggered extends \core\event\base {
* @throws \dml_exception
*/
public static function event_from_process($process) {
$data = array(
$data = [
'context' => \context_system::instance(),
'other' => array(
'other' => [
'processid' => $process->id,
'workflowid' => $process->workflowid,
'courseid' => $process->courseid
)
);
'courseid' => $process->courseid,
],
];
return self::create($data);
}

Expand Down
4 changes: 2 additions & 2 deletions classes/local/form/form_courses_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public function definition() {
$mform->setType('fullname', PARAM_TEXT);

// Edited from $this->add_action_buttons to allow custom cancel text.
$buttonarray = array();
$buttonarray = [];
$buttonarray[] = &$mform->createElement('submit', 'submitbutton',
get_string('apply', 'tool_lifecycle'));
$buttonarray[] = &$mform->createElement('cancel', 'cancel', get_string('reset'));
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$mform->addGroup($buttonarray, 'buttonar', '', [' '], false);
$mform->closeHeaderBefore('buttonar');
}

Expand Down
2 changes: 1 addition & 1 deletion classes/local/form/form_delays_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function definition() {
$activeworkflows = workflow_manager::get_active_workflows();
$workflowoptions = [
'' => get_string('all_delays', 'tool_lifecycle'),
'global' => get_string('globally', 'tool_lifecycle')
'global' => get_string('globally', 'tool_lifecycle'),
];
foreach ($activeworkflows as $activeworkflow) {
// Only show non-static workflows.
Expand Down
4 changes: 2 additions & 2 deletions classes/local/form/form_step_instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ private function add_cancel_button() {
$mform =& $this->_form;

// Add a group 'buttonar' to allow excluding it from freezing.
$buttonarray = array();
$buttonarray = [];
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$mform->addGroup($buttonarray, 'buttonar', '', [' '], false);
$mform->closeHeaderBefore('buttonar');
}

Expand Down
4 changes: 2 additions & 2 deletions classes/local/form/form_trigger_instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ public function definition() {
private function add_cancel_button() {
$mform =& $this->_form;

$buttonarray = array();
$buttonarray = [];
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$mform->addGroup($buttonarray, 'buttonar', '', [' '], false);
$mform->closeHeaderBefore('buttonar');
}

Expand Down
2 changes: 1 addition & 1 deletion classes/local/form/form_upload_workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function definition() {
$mform = $this->_form;

$mform->addElement('filepicker', 'backupfile', get_string('file'), null,
array('accepted_types' => 'xml'));
['accepted_types' => 'xml']);
$this->add_action_buttons('true', get_string('upload'));
}

Expand Down
6 changes: 3 additions & 3 deletions classes/local/manager/backup_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static function create_course_backup($courseid) {
*/
public static function restore_course_backup($backupid) {
global $DB, $CFG;
$backuprecord = $DB->get_record('tool_lifecycle_backups', array('id' => $backupid));
$backuprecord = $DB->get_record('tool_lifecycle_backups', ['id' => $backupid]);

// Check if backup tmp dir exists.
$backuptmpdir = $CFG->tempdir . DIRECTORY_SEPARATOR . 'backup';
Expand All @@ -125,10 +125,10 @@ public static function restore_course_backup($backupid) {

$context = \context_system::instance();
$restoreurl = new \moodle_url('/backup/restore.php',
array(
[
'contextid' => $context->id,
'filename' => $targetfilename,
)
]
);
redirect($restoreurl);

Expand Down
16 changes: 8 additions & 8 deletions classes/local/manager/delayed_courses_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function set_course_delayed_for_workflow($courseid, $becauserollba
} else {
$delayeduntil = time() + $duration;
$record = $DB->get_record('tool_lifecycle_delayed_workf',
array('courseid' => $courseid, 'workflowid' => $workflow->id));
['courseid' => $courseid, 'workflowid' => $workflow->id]);
if (!$record) {
$record = new \stdClass();
$record->courseid = $courseid;
Expand All @@ -86,7 +86,7 @@ public static function set_course_delayed_for_workflow($courseid, $becauserollba
public static function get_delayed_courses_for_workflow($workflowid) {
global $DB;
$sql = 'SELECT courseid FROM {tool_lifecycle_delayed_workf} WHERE delayeduntil > :now AND workflowid = :workflowid';
return $DB->get_fieldset_sql($sql, array('now' => time(), 'workflowid' => $workflowid));
return $DB->get_fieldset_sql($sql, ['now' => time(), 'workflowid' => $workflowid]);
}

/**
Expand All @@ -98,7 +98,7 @@ public static function get_delayed_courses_for_workflow($workflowid) {
public static function set_course_delayed($courseid, $duration) {
global $DB;
$delayeduntil = time() + $duration;
$record = $DB->get_record('tool_lifecycle_delayed', array('courseid' => $courseid));
$record = $DB->get_record('tool_lifecycle_delayed', ['courseid' => $courseid]);
if (!$record) {
$record = new \stdClass();
$record->courseid = $courseid;
Expand All @@ -120,7 +120,7 @@ public static function set_course_delayed($courseid, $duration) {
*/
public static function get_course_delayed($courseid) {
global $DB;
$record = $DB->get_record('tool_lifecycle_delayed', array('courseid' => $courseid));
$record = $DB->get_record('tool_lifecycle_delayed', ['courseid' => $courseid]);
if ($record) {
return $record->delayeduntil;
} else {
Expand All @@ -134,8 +134,8 @@ public static function get_course_delayed($courseid) {
*/
public static function get_course_delayed_wheresql() {
$where = "{course}.id IN (SELECT courseid FROM {tool_lifecycle_delayed} WHERE delayeduntil > :now)";
$params = array("now" => time());
return array($where, $params);
$params = ["now" => time()];
return [$where, $params];
}

/**
Expand All @@ -146,7 +146,7 @@ public static function get_course_delayed_wheresql() {
public static function get_globally_delayed_courses() {
global $DB;
$sql = 'SELECT courseid FROM {tool_lifecycle_delayed} WHERE delayeduntil > :now';
return $DB->get_fieldset_sql($sql, array('now' => time()));
return $DB->get_fieldset_sql($sql, ['now' => time()]);
}

/**
Expand All @@ -156,6 +156,6 @@ public static function get_globally_delayed_courses() {
*/
public static function remove_delay_entry($courseid) {
global $DB;
$DB->delete_records('tool_lifecycle_delayed', array('courseid' => $courseid));
$DB->delete_records('tool_lifecycle_delayed', ['courseid' => $courseid]);
}
}
8 changes: 4 additions & 4 deletions classes/local/manager/process_data_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class process_data_manager {
*/
public static function get_process_data($processid, $stepid, $key) {
global $DB;
$params = array(
$params = [
'processid' => $processid,
'keyname' => $key,
);
];
if (step_manager::is_process_data_instance_dependent($stepid)) {
$params['stepid'] = $stepid;
} else {
Expand All @@ -78,10 +78,10 @@ public static function get_process_data($processid, $stepid, $key) {
*/
public static function set_process_data($processid, $stepid, $key, $value) {
global $DB;
$entry = array(
$entry = [
'processid' => $processid,
'keyname' => $key,
);
];
if (step_manager::is_process_data_instance_dependent($stepid)) {
$entry['stepid'] = $stepid;
} else {
Expand Down
14 changes: 7 additions & 7 deletions classes/local/manager/process_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static function manually_trigger_process($courseid, $triggerid) {
public static function get_processes() {
global $DB;
$records = $DB->get_records('tool_lifecycle_process');
$processes = array();
$processes = [];
foreach ($records as $record) {
$processes[] = process::from_record($record);
}
Expand All @@ -103,7 +103,7 @@ public static function get_processes() {
*/
public static function get_process_by_id($processid) {
global $DB;
$record = $DB->get_record('tool_lifecycle_process', array('id' => $processid));
$record = $DB->get_record('tool_lifecycle_process', ['id' => $processid]);
if ($record) {
return process::from_record($record);
} else {
Expand All @@ -119,7 +119,7 @@ public static function get_process_by_id($processid) {
*/
public static function count_processes_by_workflow($workflowid) {
global $DB;
return $DB->count_records('tool_lifecycle_process', array('workflowid' => $workflowid));
return $DB->count_records('tool_lifecycle_process', ['workflowid' => $workflowid]);
}

/**
Expand All @@ -130,8 +130,8 @@ public static function count_processes_by_workflow($workflowid) {
*/
public static function get_processes_by_workflow($workflowid) {
global $DB;
$records = $DB->get_records('tool_lifecycle_process', array('workflowid' => $workflowid));
$processes = array();
$records = $DB->get_records('tool_lifecycle_process', ['workflowid' => $workflowid]);
$processes = [];
foreach ($records as $record) {
$processes[] = process::from_record($record);
}
Expand Down Expand Up @@ -201,7 +201,7 @@ public static function rollback_process($process) {
*/
private static function remove_process($process) {
global $DB;
$DB->delete_records('tool_lifecycle_procdata', array('processid' => $process->id));
$DB->delete_records('tool_lifecycle_procdata', ['processid' => $process->id]);
$DB->delete_records('tool_lifecycle_process', (array) $process);
}

Expand All @@ -213,7 +213,7 @@ private static function remove_process($process) {
*/
public static function get_process_by_course_id($courseid) {
global $DB;
$record = $DB->get_record('tool_lifecycle_process', array('courseid' => $courseid));
$record = $DB->get_record('tool_lifecycle_process', ['courseid' => $courseid]);
if ($record) {
return process::from_record($record);
} else {
Expand Down
14 changes: 7 additions & 7 deletions classes/local/manager/settings_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ public static function save_settings($instanceid, $type, $subpluginname, $data,
$cleanedvalue = clean_param($value, $setting->paramtype);
}
$record = $DB->get_record('tool_lifecycle_settings',
array(
[
'instanceid' => $instanceid,
'type' => $type,
'name' => $setting->name)
'name' => $setting->name, ]
);
if ($record) {
if ($record->value != $cleanedvalue) {
Expand Down Expand Up @@ -164,11 +164,11 @@ public static function get_settings($instanceid, $type) {
$lib = lib_manager::get_step_lib($instance->subpluginname);
}

$settingsvalues = array();
$settingsvalues = [];
foreach ($lib->instance_settings() as $setting) {
$record = $DB->get_record('tool_lifecycle_settings', array('instanceid' => $instanceid,
$record = $DB->get_record('tool_lifecycle_settings', ['instanceid' => $instanceid,
'type' => $type,
'name' => $setting->name));
'name' => $setting->name, ]);
if ($record) {
$value = clean_param($record->value, $setting->paramtype);
$settingsvalues[$setting->name] = $value;
Expand All @@ -189,8 +189,8 @@ public static function remove_settings($instanceid, $type) {
self::validate_type($type);

$DB->delete_records('tool_lifecycle_settings',
array('instanceid' => $instanceid,
'type' => $type));
['instanceid' => $instanceid,
'type' => $type, ]);
}

/**
Expand Down
Loading

0 comments on commit 421cc45

Please sign in to comment.