From e81b7b74874683494913ec5b53d996cca46c0f99 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 5b1a61a52556d..916c0dcfafd2f 100644 --- a/mod/lti/backup/moodle2/restore_lti_stepslib.php +++ b/mod/lti/backup/moodle2/restore_lti_stepslib.php @@ -86,8 +86,8 @@ protected function process_lti($data) { // 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);