Notice: Undefined property: stdClass::$mnet_localhost_id in C:\Program Files\server\htdocs\moodle\lib\accesslib.php on line 1814

Notice: Undefined property: stdClass::$mnet_localhost_id in C:\Program Files\server\htdocs\moodle\lib\accesslib.php on line 1814

by Tristan Call -
Number of replies: 1

I'm getting a rather weird error that only recently appeared. I have an activity and am viewing the view.php page of said activity. In that page I instantiate a class ($functions = new mod_distributedquiz_functions();). Instantiating this class is causing an error message to occur (at the end) even if the class consists only of the code:

defined('MOODLE_INTERNAL') || die();

require(__DIR__.'\..\..\..\config.php');

class mod_distributedquiz_functions {}

If I comment out my calling of the class everything works fine, which as far as I can tell shouldn't be the case since all the class is doing is existing. I'm using moodle 3.10.2 and have tried purging the caches.


Error Message:

Notice: Undefined property: stdClass::$mnet_localhost_id in C:\Program Files\server\htdocs\moodle\lib\accesslib.php on line 1814

Notice: Undefined property: stdClass::$debugdeveloper in C:\Program Files\server\htdocs\moodle\lib\dml\moodle_database.php on line 1100

Notice: Undefined property: stdClass::$forced_plugin_settings in C:\Program Files\server\htdocs\moodle\lib\moodlelib.php on line 1477

Warning: array_key_exists() expects parameter 2 to be array, null given in C:\Program Files\server\htdocs\moodle\lib\moodlelib.php on line 1477

Notice: Undefined property: stdClass::$dirroot in C:\Program Files\server\htdocs\moodle\lib\outputlib.php on line 2329

Notice: Undefined property: stdClass::$dirroot in C:\Program Files\server\htdocs\moodle\lib\classes\string_manager_standard.php on line 139

Notice: Undefined property: stdClass::$dirroot in C:\Program Files\server\htdocs\moodle\lib\classes\string_manager_standard.php on line 139

Notice: Undefined property: stdClass::$dirroot in C:\Program Files\server\htdocs\moodle\lib\setuplib.php on line 683

Warning: include(/version.php): failed to open stream: No such file or directory in C:\Program Files\server\htdocs\moodle\lib\setuplib.php on line 683

Warning: include(): Failed opening '/version.php' for inclusion (include_path='C:\Program Files\server\htdocs\moodle/lib/pear;C:\Program Files\server\php\PEAR') in C:\Program Files\server\htdocs\moodle\lib\setuplib.php on line 683

Notice: Undefined variable: branch in C:\Program Files\server\htdocs\moodle\lib\setuplib.php on line 689

Notice: Undefined property: stdClass::$forced_plugin_settings in C:\Program Files\server\htdocs\moodle\lib\moodlelib.php on line 1477

Warning: array_key_exists() expects parameter 2 to be array, null given in C:\Program Files\server\htdocs\moodle\lib\moodlelib.php on line 1477

Notice: Undefined property: stdClass::$dirroot in C:\Program Files\server\htdocs\moodle\lib\outputlib.php on line 2329

Notice: Undefined property: stdClass::$dirroot in C:\Program Files\server\htdocs\moodle\lib\classes\string_manager_standard.php on line 139

debug/codingerror

Notice: Undefined property: stdClass::$dirroot in C:\Program Files\server\htdocs\moodle\lib\classes\string_manager_standard.php on line 139

Notice: Undefined property: stdClass::$dirroot in C:\Program Files\server\htdocs\moodle\lib\setuplib.php on line 683

Warning: include(/version.php): failed to open stream: No such file or directory in C:\Program Files\server\htdocs\moodle\lib\setuplib.php on line 683

Warning: include(): Failed opening '/version.php' for inclusion (include_path='C:\Program Files\server\htdocs\moodle/lib/pear;C:\Program Files\server\php\PEAR') in C:\Program Files\server\htdocs\moodle\lib\setuplib.php on line 683

Notice: Undefined variable: branch in C:\Program Files\server\htdocs\moodle\lib\setuplib.php on line 689
debug/codingerror

Average of ratings: -
In reply to Tristan Call

Re: Notice: Undefined property: stdClass::$mnet_localhost_id in C:\Program Files\server\htdocs\moodle\lib\accesslib.php on line 1814

by Tristan Call -
Found the answer, and I figured I'd post it for anyone who stumbles upon this post. Turns out the error was in functions.php, and it only showed up when I instantiated the class because php is an interpreted language. As functions.php was only compiled when called.

The error itself was including an unnecessary 'require(__DIR__.'\..\..\..\config.php');' that, once removed, fixed the problem.