Getting Exception - Cannot access private property cm_info::$uservisible

Getting Exception - Cannot access private property cm_info::$uservisible

by Sushma R -
Number of replies: 4

Hi team,

I am getting " Exception - Cannot access private property cm_info::$uservisible" error when i try open the course, This is causing issue for the students who are the participants of the course, Can anyone help me on the same.


Thanks in advance

Average of ratings: -
In reply to Sushma R

Re: Getting Exception - Cannot access private property cm_info::$uservisible

by lior gil -
Picture of Core developers
You cannot access this variable directly since it's private.
However, you cant write
$cm->uservisible
since this will invoke the __get() function that will return the private value.
In reply to lior gil

Re: Getting Exception - Cannot access private property cm_info::$uservisible

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It is slighly tricker than that, and the behaviour changed with PHP 7.4, it seems.

In some code, if someting tries to access $cm->uservisible, then that will indeed call __get.

However, for the cm_info class, __get does a bunch of complicated stuff, if any of the code called directly or indirectly by __get ends up making another attempt to access $cm->uservisible, then that will lead to the error reported here.

If you turn on developer debugging, then you can work out if that is what is happening from the stack trace of the error.
In reply to Tim Hunt

Re: Getting Exception - Cannot access private property cm_info::$uservisible

by Sushma R -
This is error shown in the moodle UI, any idea what might be causing this issue? This is blocker for us to move ahead.
In reply to Sushma R

Re: Getting Exception - Cannot access private property cm_info::$uservisible

by Benjamin Ellis -
Picture of Particularly helpful Moodlers
Hi,

Is it happening in a single course or all courses? If in only one course, have you got a different course template??? If you turn on debugging, you could possibly find out what is causing the issue - something has to have changed - what has changed - the answer may be there.