MDL-77350 badges: 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.
This commit is contained in:
Meirza 2023-01-19 22:09:16 +07:00
parent 078055a51f
commit 3895529b74
7 changed files with 66 additions and 3 deletions

View File

@ -81,7 +81,7 @@ class backpack_api2p1 {
if (!empty($externalbackpack)) {
$this->externalbackpack = $externalbackpack;
$this->backpackapiversion = $externalbackpack->apiversion;
$this->get_clientid = $this->get_clientid($externalbackpack->oauth2_issuerid);
$this->get_clientid($externalbackpack->oauth2_issuerid);
if (!($this->tokendata = $this->get_stored_token($externalbackpack->id))
&& $this->backpackapiversion != OPEN_BADGES_V2P1) {

View File

@ -67,6 +67,12 @@ class backpack_api2p1_mapping {
/** @var boolean Differentiate the function that can be called on a user backpack or a site backpack. */
private $isuserbackpack;
/** @var mixed List of parameters for this method. */
protected $postparams;
/** @var int OpenBadges version 1 or 2. */
protected $backpackapiversion;
/**
* Create a mapping.
*

View File

@ -79,6 +79,12 @@ class backpack_api_mapping {
/** @var string Error string from authentication request. */
private static $authenticationerror = '';
/** @var mixed List of parameters for this method. */
protected $postparams;
/** @var int OpenBadges version 1 or 2. */
protected $backpackapiversion;
/**
* Create a mapping.
*

View File

@ -129,6 +129,24 @@ class badge {
/** @var array Badge criteria */
public $criteria = array();
/** @var int|null Total users which have the award. Called from badges_get_badges() */
public $awards;
/** @var string|null The name of badge status. Called from badges_get_badges() */
public $statstring;
/** @var int|null The date the badges were issued. Called from badges_get_badges() */
public $dateissued;
/** @var string|null Unique hash. Called from badges_get_badges() */
public $uniquehash;
/** @var string|null Message format. Called from file_prepare_standard_editor() */
public $messageformat;
/** @var array Message editor. Called from file_prepare_standard_editor() */
public $message_editor = [];
/**
* Constructs with badge details.
*
@ -240,7 +258,16 @@ class badge {
foreach (get_object_vars($this) as $k => $v) {
$fordb->{$k} = $v;
}
// TODO: We need to making it more simple.
// Since the variables are not exist in the badge table,
// unsetting them is a must to avoid errors.
unset($fordb->criteria);
unset($fordb->awards);
unset($fordb->statstring);
unset($fordb->dateissued);
unset($fordb->uniquehash);
unset($fordb->messageformat);
unset($fordb->message_editor);
$fordb->timemodified = time();
if ($DB->update_record_raw('badge', $fordb)) {

View File

@ -39,6 +39,12 @@ use core_badges\external\backpack_exporter;
*/
class external_backpacks_page implements \renderable {
/** @var \moodle_url Badges backpacks URL. */
protected $url;
/** @var array List the backpacks at site level. */
protected $backpacks = [];
/**
* Constructor.
* @param \moodle_url $url

View File

@ -48,9 +48,9 @@ class external_backpacks_table extends table_sql {
public function __construct() {
parent::__construct('backpacks');
$this->context = \context_system::instance();
$context = \context_system::instance();
// This object should not be used without the right permissions.
require_capability('moodle/badges:manageglobalsettings', $this->context);
require_capability('moodle/badges:manageglobalsettings', $context);
// Define columns in the table.
$this->define_table_columns();

View File

@ -128,6 +128,24 @@ abstract class award_criteria {
*/
public $params = array();
/**
* Criteria type.
* @var string
*/
public $criteriatype;
/**
* Required parameters.
* @var string
*/
public $required_param = '';
/**
* Optional parameters.
* @var array
*/
public $optional_params = [];
/**
* The base constructor
*