mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 20:50:21 +01:00
MDL-76356 various: avoid implicit conversion to arrays
PHP before version 8.1 automatically converted stdClass or 'false' to arrays if function parameter expects array (for example, "reset"). PHP 8.1 shows notices in these situations
This commit is contained in:
parent
cd072308e5
commit
66dcb1683b
@ -187,7 +187,7 @@ class provider_test extends provider_testcase {
|
||||
$writer = writer::with_context($context);
|
||||
$this->assertTrue($writer->has_any_data());
|
||||
if ($context->contextlevel == CONTEXT_MODULE) {
|
||||
if ($data = $writer->get_data($subcontextstudent)) {
|
||||
if ($data = (array)$writer->get_data($subcontextstudent)) {
|
||||
$this->assertEquals($user->id, reset($data)->userid);
|
||||
}
|
||||
if ($data = (array)$writer->get_data($subcontextrc)) {
|
||||
|
@ -278,7 +278,7 @@ class page_agreedocs implements renderable, templatable {
|
||||
$cache = \cache::make('core', 'presignup');
|
||||
$cachekey = 'tool_policy_viewedpolicies';
|
||||
|
||||
$viewedpolicies = $cache->get($cachekey);
|
||||
$viewedpolicies = $cache->get($cachekey) ?: [];
|
||||
if (!empty($viewedpolicies)) {
|
||||
// Get the list of the policies docs which the user haven't viewed during this session.
|
||||
$pendingpolicies = array_diff($currentpolicyversionids, $viewedpolicies);
|
||||
|
@ -99,7 +99,7 @@ class calculation_info {
|
||||
$samplekey = self::get_sample_key($uniquesampleid);
|
||||
|
||||
// Update the cached data adding the new indicator data.
|
||||
$cacheddata = $cache->get($samplekey);
|
||||
$cacheddata = $cache->get($samplekey) ?: [];
|
||||
$cacheddata[$calculableclass] = $infokeys;
|
||||
$cache->set($samplekey, $cacheddata);
|
||||
}
|
||||
|
@ -305,7 +305,9 @@ class helper_test extends \advanced_testcase {
|
||||
$this->assertTrue(empty($messages->info));
|
||||
|
||||
// Add an some messages manually and check they are still there.
|
||||
$messages->error = [];
|
||||
$messages->error['error1'] = 'Testing ERROR message';
|
||||
$messages->info = [];
|
||||
$messages->info['info1'] = 'Testing INFO message';
|
||||
$messages->info['info2'] = 'Testing INFO message';
|
||||
helper::get_messages($messages, $factory);
|
||||
|
@ -1055,7 +1055,7 @@ class completion_info {
|
||||
if (!isset($this->course->cacherev)) {
|
||||
$this->course = get_course($this->course_id);
|
||||
}
|
||||
if ($cacheddata = $completioncache->get($key)) {
|
||||
if ($cacheddata = ($completioncache->get($key) ?: [])) {
|
||||
if ($cacheddata['cacherev'] != $this->course->cacherev) {
|
||||
// Course structure has been changed since the last caching, forget the cache.
|
||||
$cacheddata = array();
|
||||
|
Loading…
x
Reference in New Issue
Block a user