Skip to content

Throws an exception when a user without mod/certifygen:addinstance capability accesses its profile #120

@jmerinogranizo

Description

@jmerinogranizo

Plugin version: v1.0.3 (2025112100)
Moodle version: 4.5.X

A user without mod/certifygen:addinstance capability accesess its profile and the system throw the next exception:

Got error 'PHP message: Default exception handler: Excepci\xc3\xb3n - count(): Argument #1 ($value) must be of type Countable|array, bool given Debug:
\n Error code: generalexceptionmessage
\n* line 152 of /mod/certifygen/classes/persistents/certifygen_context.php: TypeError thrown
\n* line 152 of /mod/certifygen/classes/persistents/certifygen_context.php: call to count()
\n* line 320 of /mod/certifygen/lib.php: call to mod_certifygen\persistents\certifygen_context::can_i_see_teacherrequestlink()
\n* line 75 of /user/classes/output/myprofile/manager.php: call to mod_certifygen_myprofile_navigation()
\n* line 229 of /user/profile.php: call to core_user\output\myprofile\manager::build_tree()\n'

The problem is in the method can_i_see_teacherrequestlink of the class mod/certifygen/classes/persistents/certifygen_context.php

It should be sustituted the line

$numresult = count($result);

by

$numresult = (is_countable ($result)) ? count($result) : 0;

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions