Exception - syntax error, unexpected '|', expecting ';', or '{'
Re: Exception - syntax error, unexpected '|', expecting ';', or '{'
Enable debugging to show more details with the error. If the error is preventing you getting to the settings you can instead add the following lines to config.php
:
@error_reporting(E_ALL | E_STRICT);
@ini_set('display_errors', '1');
$CFG->debug = (E_ALL | E_STRICT);
$CFG->debugdisplay = 1;
These lines must appear before the require_once(__DIR__ . '/lib/setup.php');
line.
This kind of error is frequently due to a mismatch between the version of Moodle or a plugin, and the PHP version.
Re: Exception - syntax error, unexpected '|', expecting ';', or '{'
I have added the code as you suggested. This is what I get. Ideas?
Exception - syntax error, unexpected '|', expecting ';' or '{'
More information about this error
Debug info:
Error code: generalexceptionmessage×Dismiss this notification
Stack trace:
line 96 of /admin/tool/mfa/classes/plugininfo/factor.php: ParseError thrown
line ? of unknownfile: call to core_component::classloader()
line ? of unknownfile: call to spl_autoload_call()
line 450 of /lib/classes/plugin_manager.php: call to class_exists()
line 261 of /lib/classes/plugin_manager.php: call to core_plugin_manager::resolve_plugininfo_class()
line 282 of /lib/classes/plugin_manager.php: call to core_plugin_manager->load_enabled_plugins()
line 197 of /availability/classes/tree.php: call to core_plugin_manager->get_enabled_plugins()
line 144 of /availability/classes/info.php: call to core_availability\tree->__construct()
line 114 of /availability/classes/info.php: call to core_availability\info->decode_availability()
line 196 of /availability/classes/info.php: call to core_availability\info->get_availability_tree()
line 3175 of /lib/modinfolib.php: call to core_availability\info->is_available()
line 3236 of /lib/modinfolib.php: call to section_info->get_available()
line 3137 of /lib/modinfolib.php: call to section_info->get_uservisible()
line 75 of /course/format/classes/output/local/content/section/summary.php: call to section_info->__get()
line 145 of /course/format/classes/output/local/content/section.php: call to core_courseformat\output\local\content\section\summary->export_for_template()
line 94 of /course/format/classes/output/local/content/frontpagesection.php: call to core_courseformat\output\local\content\section->export_for_template()
line 497 of /lib/outputrenderers.php: call to core_courseformat\output\local\content\frontpagesection->export_for_template()
line 108 of /course/format/classes/output/section_renderer.php: call to plugin_renderer_base->render()
line 2208 of /course/renderer.php: call to core_courseformat\output\section_renderer->render()
line 137 of /index.php: call to core_course_renderer->frontpage_section1()
Do you see anything here I can fix to resolve this issue? Thank you for your time.
Re: Exception - syntax error, unexpected '|', expecting ';', or '{'
As Ken's suggested, it looks like the Multi-factor authentication (tool_mfa) plugin is causing the problem. Make sure you have the latest version which supports your Moodle version.
Re: Exception - syntax error, unexpected '|', expecting ';', or '{'
Re: Exception - syntax error, unexpected '|', expecting ';', or '{'
Re: Exception - syntax error, unexpected '|', expecting ';', or '{'
The original syntax error makes some sense now: you've got some Moodle 4.3 files mixed in with you Moodle 4.0 source code.
The copy of tool_mfa wasn't the one from the Plugins directory but the one that got added to core in Moodle 4.3 and requires PHP 8.0 or later. And these new Plugin dependencies check errors are because your copy of the Database activity (mod_data) is from Moodle 4.3, which is what the Requires: Moodle 2023100400 refers to.
So you need to make sure your Moodle source code (and the plugins and themes) are all the expected version. You could do this by following the steps to upgrade to the latest minor version, i.e. if you're running Moode 4.0.x then upgrade to Moodle 4.0.12. Basically:
- Move your current Moodle source code into a backup folder.
- Download the latest Moodle 4.0.x release.
- Extract the files into your site's source code folder.
- Copy
config.php
from the backup folder into the source code folder. - Download and extract any plugins and themes you have installed.
- Log in as an admin to perform the update.
Re: Exception - syntax error, unexpected '|', expecting ';', or '{'
Many thanks to Leon and Ken!