MDL-78166 lib: Added missing class properties in portfolio

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.

Removing the existing $id property at portfolio_format_leap2a_writer, because
the $id only needed inside the __construct().
This commit is contained in:
Meirza
2023-05-27 09:29:33 +07:00
committed by meirzamoodle
parent 6b8884e13b
commit 62bd66ccf9
3 changed files with 3 additions and 9 deletions
-1
View File
@@ -197,7 +197,6 @@ abstract class portfolio_caller_base {
public final function set($field, &$value) {
if (property_exists($this, $field)) {
$this->{$field} =& $value;
$this->dirty = true;
return true;
}
$a = (object)array('property' => $field, 'class' => get_class($this));
-1
View File
@@ -167,7 +167,6 @@ class portfolio_exporter {
$this->instancefile = 'portfolio/' . $this->instance->get('plugin') . '/lib.php';
$this->instance->set('exporter', $this);
}
$this->dirty = true;
return true;
}
$a = (object)array('property' => $field, 'class' => get_class($this));
+3 -7
View File
@@ -53,9 +53,6 @@ class portfolio_format_leap2a_writer {
/** @var stdClass the user exporting data */
private $user;
/** @var string the id of the feed - this is unique to the user and date and used for portfolio ns as well as feed id */
private $id;
/** @var array the entries for the feed - keyed on id */
private $entries = array();
@@ -68,8 +65,7 @@ class portfolio_format_leap2a_writer {
public function __construct(stdclass $user) { // todo something else - exporter, format, etc
global $CFG;
$this->user = $user;
$this->exporttime = time();
$this->id = $CFG->wwwroot . '/portfolio/export/leap2a/' . $this->user->id . '/' . $this->exporttime;
$id = $CFG->wwwroot . '/portfolio/export/leap2a/' . $this->user->id . '/' . time();
$this->dom = new DomDocument('1.0', 'utf-8');
@@ -78,11 +74,11 @@ class portfolio_format_leap2a_writer {
$this->feed->setAttribute('xmlns:rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
$this->feed->setAttribute('xmlns:leap2', 'http://terms.leapspecs.org/');
$this->feed->setAttribute('xmlns:categories', 'http://wiki.leapspecs.org/2A/categories');
$this->feed->setAttribute('xmlns:portfolio', $this->id); // this is just a ns for ids of elements for convenience
$this->feed->setAttribute('xmlns:portfolio', $id); // This is just a ns for ids of elements for convenience.
$this->dom->appendChild($this->feed);
$this->feed->appendChild($this->dom->createElement('id', $this->id));
$this->feed->appendChild($this->dom->createElement('id', $id));
$this->feed->appendChild($this->dom->createElement('title', get_string('leap2a_feedtitle', 'portfolio', fullname($this->user))));
$this->feed->appendChild($this->dom->createElement('leap2:version', 'http://www.leapspecs.org/2010-07/2A/'));