Fresh Moodle install - on login to admin dashboard panel: generalexceptionmessage: Exception - Class '\tool_usertours\local\target\unattached' not found

Fresh Moodle install - on login to admin dashboard panel: generalexceptionmessage: Exception - Class '\tool_usertours\local\target\unattached' not found

by Jeremy Davis -
Number of replies: 4

I tried installing Moodle v3.8.3+ to a minimalist Debian Buster Headless server with Apache 2.4, PHP 7.3 & MariaDB 10.3 (php running via mod_php) about a month ago and hit this issue.

It seems to be related to the Dashboard tour?! I googled lots and found no other mention of the specific issue so wasn't really sure what to do...

Perhaps it was the wrong approach, but I posted a bug report. I didn't get any feedback so ended up abandoning my server.

Now a month later, I just tried again today, and hit exactly the same issue?! I find it bizarre that I seem to be able to reliably recreate this issue but no one else appears to have reported it?!

It makes me wonder whether I have a missing dependency (e.g. php module), incorrect permissions or perhaps some incorrect config?

This time I tried setting really permissive permissions and that appeared to make no difference. I also enabled debugging, and as noted on my bug report, I got a stacktrace which might be of more value than the error message?!:

Error code: generalexceptionmessage
* line 117 of /admin/tool/usertours/classes/target.php: Error thrown
* line 297 of /admin/tool/usertours/classes/step.php: call to tool_usertours\target::get_target_instance()
* line 77 of /admin/tool/usertours/classes/output/step.php: call to tool_usertours\step->get_target()
* line 66 of /admin/tool/usertours/classes/output/tour.php: call to tool_usertours\output\step->export_for_template()
* line 80 of /admin/tool/usertours/classes/external/tour.php: call to tool_usertours\output\tour->export_for_template()
* line 244 of /lib/externallib.php: call to tool_usertours\external\tour::fetch_and_start_tour()
* line 79 of /lib/ajax/service.php: call to external_api::call_external_function()

I guess it may not be that big a deal in the grand scheme of things, but I'd really like to understand the issue and ideally fix it, then I can feel confident about Moodle. If anyone has any ideas, I'd be eternally grateful....

Average of ratings: -
In reply to Jeremy Davis

Re: Fresh Moodle install - on login to admin dashboard panel: generalexceptionmessage: Exception - Class '\tool_usertours\local\target\unattached' not found

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It's a tricky one. 'Generalexceptionmessage' is about as unhelpful as it gets plus the usertours code isn't especially readable.

It seems to fail in a line where it tries to instantiate a new class (with a variable name). My guess is that the name is null or the class doesn't exist. This would take some proper debugging.

If you haven't done already, check your web server's error log. I'm hoping that there might be a notice or warning that indicates an earlier step in this problem.
Average of ratings: Useful (1)
In reply to Howard Miller

Re: Fresh Moodle install - on login to admin dashboard panel: generalexceptionmessage: Exception - Class '\tool_usertours\local\target\unattached' not found

by Jeremy Davis -
Thanks heaps for your input. I double checked and my Apache error.log doesn't appear to have anything of any value:

[Sat Jun 13 04:10:17.164835 2020] [ssl:warn] [pid 3646] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Jun 13 04:10:17.256256 2020] [ssl:warn] [pid 3647] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Jun 13 04:10:17.265465 2020] [mpm_prefork:notice] [pid 3647] AH00163: Apache/2.4.38 (Debian) OpenSSL/1.1.1d configured -- resuming normal operations
[Sat Jun 13 04:10:17.265548 2020] [core:notice] [pid 3647] AH00094: Command line: '/usr/sbin/apache2'
As you can see, I'm using a server name of "localhost" for Apache and it doesn't match the self signed certs I have currently (they use the actual hostname). But I'm 99.99% sure that has nothing to do with it. If you think it might, let me know and I can rule that out 100%. The access.log also doesn't appear to have anything of value either, but here it is anyway, as perhaps to a trained eye it might?!

localhost:80 192.168.1.82 - - [13/Jun/2020:04:11:23 +0000] "GET /my/ HTTP/1.1" 200 22885 "http://192.168.1.87/my/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
localhost:80 192.168.1.82 - - [13/Jun/2020:04:11:25 +0000] "GET /theme/image.php/boost/theme/1591930408/favicon HTTP/1.1" 200 1625 "http://192.168.1.87/my/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
localhost:80 192.168.1.82 - - [13/Jun/2020:04:11:25 +0000] "POST /lib/ajax/service.php?sesskey=fpHNDAt2Cl&info=core_calendar_get_calendar_monthly_view HTTP/1.1" 200 35551 "http://192.168.1.87/my/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
localhost:80 192.168.1.82 - - [13/Jun/2020:04:11:25 +0000] "POST /lib/ajax/service.php?sesskey=fpHNDAt2Cl&info=tool_usertours_fetch_and_start_tour HTTP/1.1" 200 1395 "http://192.168.1.87/my/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
localhost:80 192.168.1.82 - - [13/Jun/2020:04:11:25 +0000] "POST /lib/ajax/service.php?sesskey=fpHNDAt2Cl&info=core_course_get_recent_courses HTTP/1.1" 200 332 "http://192.168.1.87/my/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
localhost:80 192.168.1.82 - - [13/Jun/2020:04:11:26 +0000] "POST /lib/ajax/service.php?sesskey=fpHNDAt2Cl&info=core_fetch_notifications HTTP/1.1" 200 331 "http://192.168.1.87/my/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
localhost:80 192.168.1.82 - - [13/Jun/2020:04:11:27 +0000] "GET /lib/ajax/service-nologin.php?info=core_get_string&cachekey=1591930424&args=%5B%7B%22index%22%3A0%2C%22methodname%22%3A%22core_get_string%22%2C%22args%22%3A%7B%22stringparams%22%3A%5B%5D%2C%22lang%22%3A%22en%22%7D%7D%5D HTTP/1.1" 200 841 "http://192.168.1.87/my/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
localhost:80 192.168.1.82 - - [13/Jun/2020:04:11:27 +0000] "POST /lib/ajax/service.php?sesskey=fpHNDAt2Cl&info=core_course_get_enrolled_courses_by_timeline_classification HTTP/1.1" 200 358 "http://192.168.1.87/my/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
localhost:80 192.168.1.82 - - [13/Jun/2020:04:11:27 +0000] "POST /lib/ajax/service.php?sesskey=fpHNDAt2Cl&info=core_calendar_get_action_events_by_timesort HTTP/1.1" 200 371 "http://192.168.1.87/my/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
Let me know if there is anything further you can suggest for more debugging.
In reply to Jeremy Davis

Re: Fresh Moodle install - on login to admin dashboard panel: generalexceptionmessage: Exception - Class '\tool_usertours\local\target\unattached' not found

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

This error suggests PHP can't load class tool_usertours\local\target\unattached which is defined in file admin/tool/usertours/classes/local/target/unattached.php. Does this file exist in the Moodle source code directory on the server?

If I remove that file I get what looks like the same error (with Debug messages set to "DEVELOPER"):

generalexceptionmessage: Class unattached not found


Average of ratings: Useful (2)
In reply to Leon Stringer

Re: Fresh Moodle install - on login to admin dashboard panel: generalexceptionmessage: Exception - Class '\tool_usertours\local\target\unattached' not found

by Jeremy Davis -
Awesome! Thanks for this. Turns out that there is no admin/tool/usertours/classes/local/target/ dir at all in my install!?!

Although my next questions is why/how this might have happened? And not just once, but twice in a row?! I've just downloaded the moodle-latest-38.tgz again and unpacked it:

mkdir -p /var/www/test/
cd /var/www/test/
wget https://download.moodle.org/download.php/stable38/moodle-latest-38.tgz
tar -xf moodle-latest-38.tgz 
ls moodle/admin/tool/usertours/classes/local/target/unattached.php
and that file (& directory) is there?!

Then I installed this new download via cli (FWIW I've been using the same install script: 

mkdir moodledata
php moodle/admin/cli/install.php \
    --chmod=750 \
    --lang=en \
    --wwwroot="http://192.168.1.87" \
    --dataroot=/var/www/test/moodledata \
    --dbtype=mariadb \
    --dbhost=localhost \
    --dbname=moodle2 \
    --dbuser=moodle \
    --dbpass=$MY_MOODLE_DB_PASS \
    --prefix="" \
    --fullname="My Moodle" \
    --shortname=moodle \
    --adminuser=admin \
    --adminpass=$MY_ADMIN_PASS \
    --adminemail=admin@example.com \
    --upgradekey= \
    --non-interactive \
    --agree-license
And it's still there?! So TBH, I have no idea what was going on in my previous installs?!

The only thing that I can think of (which TBH seems incredibly unlikely) is that there is some bug in the release bundling process that for some reason missed that dir when creating the archive on the 2 particular occasions that I checked...

Regardless, my issue appears to be resolved, at least for now. Thanks very much for the knowledge and insight. smile
Average of ratings: Useful (1)