From 8a5485a7148cab25145574ea176ce16a65640efd Mon Sep 17 00:00:00 2001 From: Meirza Date: Mon, 27 Mar 2023 09:18:52 +0700 Subject: [PATCH] MDL-77338 backup: Added class properties that are not declared. In PHP 8.2 and later, setting a value to an undeclared class property is deprecated and emits a deprecation notice. So we need to add missing class properties that still need to be declared. --- backup/cc/cc112moodle.php | 2 +- backup/cc/cc2moodle.php | 2 +- backup/cc/cc_lib/cc_asssesment.php | 9 +++++++++ backup/cc/cc_lib/cc_organization.php | 6 ++++-- backup/cc/cc_lib/cc_version1.php | 3 +++ backup/cc/validator.php | 1 - backup/controller/base_controller.class.php | 3 +++ backup/moodle2/restore_stepslib.php | 3 +++ backup/moodle2/tests/restore_stepslib_date_test.php | 2 +- backup/util/settings/tests/settings_test.php | 5 ----- backup/util/xml/output/xml_output.class.php | 3 +++ backup/util/xml/parser/progressive_parser.class.php | 1 - 12 files changed, 28 insertions(+), 12 deletions(-) diff --git a/backup/cc/cc112moodle.php b/backup/cc/cc112moodle.php index 9e11533f6f5..faafa20d808 100644 --- a/backup/cc/cc112moodle.php +++ b/backup/cc/cc112moodle.php @@ -123,7 +123,7 @@ class cc112moodle extends cc2moodle { if (array_key_exists("index", self::$instances)) { if (!file_put_contents(static::$path_to_manifest_folder . DIRECTORY_SEPARATOR . 'moodle.xml', $result_xml)) { - static::log_action('Cannot save the moodle manifest file: ' . static::$path_to_tmp_folder . DIRECTORY_SEPARATOR . 'moodle.xml', true); + static::log_action('Cannot save the moodle manifest file: ' . static::$path_to_manifest_folder . DIRECTORY_SEPARATOR . 'moodle.xml', true); } else { $status = true; } diff --git a/backup/cc/cc2moodle.php b/backup/cc/cc2moodle.php index 245065afe70..291611117ce 100644 --- a/backup/cc/cc2moodle.php +++ b/backup/cc/cc2moodle.php @@ -206,7 +206,7 @@ class cc2moodle { if (array_key_exists("index", self::$instances)) { if (!file_put_contents(static::$path_to_manifest_folder . DIRECTORY_SEPARATOR . 'moodle.xml', $result_xml)) { - static::log_action('Cannot save the moodle manifest file: ' . static::$path_to_tmp_folder . DIRECTORY_SEPARATOR . 'moodle.xml', true); + static::log_action('Cannot save the moodle manifest file: ' . static::$path_to_manifest_folder . DIRECTORY_SEPARATOR . 'moodle.xml', true); } else { $status = true; } diff --git a/backup/cc/cc_lib/cc_asssesment.php b/backup/cc/cc_lib/cc_asssesment.php index bbc5650911b..4ff68cc2805 100644 --- a/backup/cc/cc_lib/cc_asssesment.php +++ b/backup/cc/cc_lib/cc_asssesment.php @@ -1042,6 +1042,9 @@ class cc_assesment_itemfeedbacktype extends cc_question_metadata_base { protected $solution = null; protected $hint = null; + /** @var cc_assignment_displayfeedbacktype item feedback. */ + protected $itemfeedback; + public function __construct() { $this->set_setting(cc_qti_tags::ident, cc_helpers::uuidgen('I_')); $this->set_setting(cc_qti_tags::title); @@ -1386,6 +1389,12 @@ class cc_assesment_flow_labeltype extends cc_question_metadata_base { */ protected $response_label = null; + /** @var cc_assesment_material assesment material. */ + protected $material; + + /** @var cc_assesment_response_matref assesment response material ref. */ + protected $material_ref; + public function __construct() { $this->set_setting(cc_qti_tags::t_class); } diff --git a/backup/cc/cc_lib/cc_organization.php b/backup/cc/cc_lib/cc_organization.php index 3720f014184..ecaa4558028 100644 --- a/backup/cc/cc_lib/cc_organization.php +++ b/backup/cc/cc_lib/cc_organization.php @@ -42,7 +42,8 @@ class cc_organization implements cc_i_organization { private $metadata = null; private $sequencing = null; - + /** @var bool true if empty, otherwise false. */ + protected $isempty; public function __construct($node=null, $doc=null) { if (is_object($node) && is_object($doc)) { @@ -140,7 +141,8 @@ class cc_item implements cc_i_item { private $parentItem = null; private $isempty = true; - + /** @var mixed node structure. */ + public $structure; public function __construct($node=null,$doc=null) { if (is_object($node)) { diff --git a/backup/cc/cc_lib/cc_version1.php b/backup/cc/cc_lib/cc_version1.php index f68cb58e535..b6b30779d90 100644 --- a/backup/cc/cc_lib/cc_version1.php +++ b/backup/cc/cc_lib/cc_version1.php @@ -37,6 +37,9 @@ class cc_version1 extends cc_version_base { const discussiontopic = 'imsdt_xmlv1p0'; const weblink = 'imswl_xmlv1p0'; + /** @var array CC URL profiles. */ + protected $ccnsnames = []; + public static $checker = array(self::webcontent, self::assessment, self::associatedcontent, diff --git a/backup/cc/validator.php b/backup/cc/validator.php index ba125544c10..510a403cb57 100644 --- a/backup/cc/validator.php +++ b/backup/cc/validator.php @@ -210,7 +210,6 @@ class cc_validate_type { * @return boolean */ public function validate($element) { - $this->last_error = null; $celement = realpath($element); $cvalidator = realpath($this->location.DIRECTORY_SEPARATOR.$this->type); $result = (empty($celement) || empty($cvalidator)); diff --git a/backup/controller/base_controller.class.php b/backup/controller/base_controller.class.php index 57dc8674ab0..a932ca25fbd 100644 --- a/backup/controller/base_controller.class.php +++ b/backup/controller/base_controller.class.php @@ -43,6 +43,9 @@ abstract class base_controller extends backup implements loggable { */ protected $copy; + /** @var int Backup mode. */ + protected $mode; + /** * Gets the progress reporter, which can be used to report progress within * the backup or restore process. diff --git a/backup/moodle2/restore_stepslib.php b/backup/moodle2/restore_stepslib.php index ad500d034ab..eb820930973 100644 --- a/backup/moodle2/restore_stepslib.php +++ b/backup/moodle2/restore_stepslib.php @@ -6169,6 +6169,9 @@ abstract class restore_questions_activity_structure_step extends restore_activit use restore_question_reference_data_trait; use restore_question_set_reference_data_trait; + /** @var \question_engine_attempt_upgrader manages upgrading all the question attempts. */ + private $attemptupgrader; + /** * Attach below $element (usually attempts) the needed restore_path_elements * to restore question attempt data from Moodle 2.0. diff --git a/backup/moodle2/tests/restore_stepslib_date_test.php b/backup/moodle2/tests/restore_stepslib_date_test.php index 22fad29710d..4c79d86a1cb 100644 --- a/backup/moodle2/tests/restore_stepslib_date_test.php +++ b/backup/moodle2/tests/restore_stepslib_date_test.php @@ -144,7 +144,7 @@ class restore_stepslib_date_test extends \restore_date_testcase { $fordb->status = BADGE_STATUS_INACTIVE; $fordb->nextcron = time(); - $this->badgeid = $DB->insert_record('badge', $fordb, true); + $DB->insert_record('badge', $fordb, true); // Do a backup and restore. $newcourseid = $this->backup_and_restore($course); $newcourse = get_course($newcourseid); diff --git a/backup/util/settings/tests/settings_test.php b/backup/util/settings/tests/settings_test.php index 92cda1134e5..a11279ca419 100644 --- a/backup/util/settings/tests/settings_test.php +++ b/backup/util/settings/tests/settings_test.php @@ -459,11 +459,6 @@ class mock_base_setting extends base_setting { $this->set_visibility($setting->get_visibility()); $this->set_status($setting->get_status()); } - - public function get_ui_info() { - // Return an array with all the ui info to be tested - return array($this->ui_type, $this->ui_label, $this->ui_values, $this->ui_options); - } } /** diff --git a/backup/util/xml/output/xml_output.class.php b/backup/util/xml/output/xml_output.class.php index 059c2f95a08..405979d001c 100644 --- a/backup/util/xml/output/xml_output.class.php +++ b/backup/util/xml/output/xml_output.class.php @@ -49,6 +49,9 @@ abstract class xml_output { protected $running; // To know if output is running + /** @var string|float finish microtime. */ + protected $finishtime; + public function __construct($usebuffer = true) { $this->inittime = microtime(true); $this->finishtime = $this->inittime; diff --git a/backup/util/xml/parser/progressive_parser.class.php b/backup/util/xml/parser/progressive_parser.class.php index a5ebc4d6238..448994723c4 100644 --- a/backup/util/xml/parser/progressive_parser.class.php +++ b/backup/util/xml/parser/progressive_parser.class.php @@ -85,7 +85,6 @@ class progressive_parser { $this->file = null; $this->contents = null; - $this->procesor = null; $this->level = 0; $this->path = ''; $this->accum = '';