From 7962f73e518269a0ab7b74bb40502c1ad7c46140 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Wed, 25 Mar 2015 01:37:33 +0100 Subject: [PATCH] MDL-49543 badges: minor tweaks Fix restore to support old criteria not having descriptions. Plus delete not-needed cast (now $params is always already array). --- backup/moodle2/restore_stepslib.php | 4 ++-- badges/criteria/award_criteria.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backup/moodle2/restore_stepslib.php b/backup/moodle2/restore_stepslib.php index 014cfb41339..209f97d75f1 100644 --- a/backup/moodle2/restore_stepslib.php +++ b/backup/moodle2/restore_stepslib.php @@ -2272,8 +2272,8 @@ class restore_badges_structure_step extends restore_structure_step { 'badgeid' => $this->get_new_parentid('badge'), 'criteriatype' => $data->criteriatype, 'method' => $data->method, - 'description' => $data->description, - 'descriptionformat' => $data->descriptionformat, + 'description' => isset($data->description) ? $data->description : '', + 'descriptionformat' => isset($data->descriptionformat) ? $data->descriptionformat : 0, ); $newid = $DB->insert_record('badge_criteria', $params); $this->set_mapping('criterion', $data->id, $newid); diff --git a/badges/criteria/award_criteria.php b/badges/criteria/award_criteria.php index 2d102dcce3a..58ccf8616fe 100644 --- a/badges/criteria/award_criteria.php +++ b/badges/criteria/award_criteria.php @@ -373,7 +373,7 @@ abstract class award_criteria { // Pick only params that are required by this criterion. // Filter out empty values first. - $params = array_filter((array)$params); + $params = array_filter($params); // Find out which param matches optional and required ones. $match = array_merge($this->optional_params, array($this->required_param)); $regex = implode('|', array_map(create_function('$a', 'return $a . "_";'), $match));