From 984470d8a1e15973c29619acc6f87733dc586fe5 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Tue, 24 Oct 2017 22:49:10 +0200 Subject: [PATCH] MDL-36580 backup: Avoid PHP notice restoring old backups Before this implementation, both resourcekey and password were not being included in the backups, so old backups are missing them. To keep upwards compatibility and avoid a PHP Notice (undefined property), existence is checked via isset(), that is the usual way all over the restore process. --- mod/lti/backup/moodle2/restore_lti_stepslib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/lti/backup/moodle2/restore_lti_stepslib.php b/mod/lti/backup/moodle2/restore_lti_stepslib.php index 4a27592aea4..f57186a2044 100644 --- a/mod/lti/backup/moodle2/restore_lti_stepslib.php +++ b/mod/lti/backup/moodle2/restore_lti_stepslib.php @@ -89,8 +89,8 @@ class restore_lti_activity_structure_step extends restore_activity_structure_ste // Try to decrypt resourcekey and password. Null if not possible (DB default). // Note these fields were originally encrypted on backup using {link @encrypted_final_element}. - $data->resourcekey = $this->decrypt($data->resourcekey); - $data->password = $this->decrypt($data->password); + $data->resourcekey = isset($data->resourcekey) ? $this->decrypt($data->resourcekey) : null; + $data->password = isset($data->password) ? $this->decrypt($data->password) : null; $newitemid = $DB->insert_record('lti', $data);