403 and 'undefined' errors in my install

403 and 'undefined' errors in my install

by Laurent Duperval -
Number of replies: 14

Hi,

I'm kinda in a bind. My Moodle install seems borked and I don't understand why.

Salient info:

  • Siteground shared hosting
  • Initial installation was done with the one-click thingie (called App Installer)  they make available for … uhm… lazy people, I guess
  • Moodle version: Moodle 4.1.9 (Build: 20240212). I haven't updated because when I looked at the upgrade procedure, I wanted to wait until I had enough time to complete it, since it wasn't simply clicking an update button.
  • No plugins
  • No themes
  • I'm not sure what changed. It's possible there was a PHP upgrade, but I'm not sure. I don't see any traces in my emails

Here are the symptoms:

  • When I click on the "forgot password" link, I get a 403 error
  • When I am logged in, I often get the Undefined error
  • The links at the top are active but the text often does not appear. If I refresh multiple times, eventually the text appears
  • I see many 403 errors in my logs. It's as iff an asset is available one moment but not the ext

I checked my file permissions and they are set to 644 so I think that's OK. Even more annoying is the fact that sometimes the text fonts appear correctly, sometimes they don't. 

I can't figure out what's wrong and it's very annoying.

If anyone can point me in the direction that might help me solve this, I would be very grateful.

In parallel, I'm going to talk to the Siteground folks who may have seen this before. If I find a solution with them, I will come back and post here so it doesn't happen to other people.

Thanks,

L

Average of ratings: -
In reply to Laurent Duperval

Re: 403 and 'undefined' errors in my install

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
We have no idea how this one-click installer installed Moodle - and nor do you I assume - which is why they make it incredibly hard to help.

A 403 error is usually due to some security setting that you may have no control over. Siteground has decided that you are not a legitimate user. It's very likely something for Siteground to fix, rather than anything in Moodle.

(403 doesn't mean something isn't available- that's 404)
In reply to Howard Miller

Re: 403 and 'undefined' errors in my install

by Laurent Duperval -
Hmmm, just got off support with Siteground and they're saying the same thing: It's not something wrong with Siteground's site so it must be something in the Moodle installation.

Here is some info from my browser console that points to the 403 errors, in case it helps pinpoint the problem:

GET https://mydomain.com/mymoodle/lib/ajax/service-nologin.php?info=core_get_string&cachekey=1715618256&args=[{"index":0,"methodname":"core_get_string","args":{"stringid":"changesmadereallygoaway","stringparams":[],"component":"moodle","lang":"en"}}]

GET https://mydomain.com/mymoodle/lib/ajax/service-nologin.php?info=core_output_load_fontawesome_icon_system_map&cachekey=1715618256&args=[{"index":0,"methodname":"core_output_load_fontawesome_icon_system_map","args":{"themename":"boost"}}]

GET https://mydomain.com/mymoodle/lib/ajax/service-nologin.php?info=7-method-calls&cachekey=1715618256&args=[{"index":0,"methodname":"core_output_load_template_with_dependencies","args":{"component":"core","template":"loading","themename":"boost","lang":"en"}},{"index":1,"methodname":"core_output_load_template_with_dependencies","args":{"component":"core","template":"modal","themename":"boost","lang":"en"}},{"index":2,"methodname":"core_output_load_template_with_dependencies","args":{"component":"core","template":"modal_backdrop","themename":"boost","lang":"en"}},{"index":3,"methodname":"core_output_load_template_with_dependencies","args":{"component":"core","template":"modal_save_cancel","themename":"boost","lang":"en"}},{"index":4,"methodname":"core_output_load_template_with_dependencies","args":{"component":"core","template":"modal_cancel","themename":"boost","lang":"en"}},{"index":5,"methodname":"core_output_load_template_with_dependencies","args":{"component":"core","template":"local/modal/alert","themename":"boost","lang":"en"}},{"index":6,"methodname":"core_output_load_template_with_dependencies","args":{"component":"core","template":"pix_icon_fontawesome","themename":"boost","lang":"en"}}]

I might have to reinstall or do an update to the latest version of Moodle. I don't know anymore.

L
In reply to Laurent Duperval

Re: 403 and 'undefined' errors in my install

by Ken Task -
Picture of Particularly helpful Moodlers

SiteGround is unique hosting as it is on Google Infrastructure AND they have developed their own panel (not cPanel/Plesk/DirectAdmin/Webmin).

You have no terminal. sad

But you should have a file browser.

Download this:

https://sos2.sosoftexas.org/sospg/sospg.zip

Use your file browser to upload the sospg.zip file to the root of your moodle code and unzip it.  (root of moodle code you will see a config.php file and a version.php file).

Then use your browser to go directly to https://yoursite/sos.html

There are 2 links for themes and clicking either one of them you will be prompted to login then it will re-direct to the admin theme settings.

Don't know if it will help or not, but it's worth a try rather than starting over!:|

'SoS', Ken

In reply to Ken Task

Re: 403 and 'undefined' errors in my install

by Laurent Duperval -
Hi,

Thanks for this file. From what I see, it's a way for me to see the links so I can access them, however it doesn't fix the undefined problem. I will need to check if the php version used is the correct version. I see that there is a way to ssh onto a siteground server so maybe I might be able to have access to the command line. If so and there's a better way to debug this, I'm all ears.

L
In reply to Laurent Duperval

Re: 403 and 'undefined' errors in my install

by Ken Task -
Picture of Particularly helpful Moodlers

Let's review ...
Siteground shared hosting - App Installer
So sounds like the App installer didn't work!   SG doesn't support applications they provide customers?

403 errors
are Forbidden error - access denied.
Has to do with ownerships/permission on moodle directories and files.

Your error lines ... point to theme and fonts - but there is ajax in there.
Do you have all the required php extensions installed for moodle?  php-sodium?

https://www.siteground.com/kb/403-forbidden-error/

In that sos page ... is there a link to PHP info?

Command line - better once you learn how to use ... PERIOD!

Moodle's PHP doc:

https://docs.moodle.org/404/en/PHP

Page above is for version 4.4 of moodle ... if you need to see lower versions of moodle change the last 4 in above url to 3,URL then becomes

https://docs.moodle.org/403/en/PHP

then 2, then 1, then 0.

php -v from moodle code directory would give us php version for php-cli - which is required to run cron job.

php -m from moodle code directory would show us all php extensions loaded.

php -i from moodle code directory would show how your php is initialized.

ls -l config.php from moodle code directory would show us ownerships and permissions on that file alone.   That file, BTW, needs to be writable by the owner of the file (probably your account login) and only readable by group and others.

Possible fixes ... chmod and chown commands on files/fodlers in moodle code but I can't give you specifics there as I don't know your login nor how SG App Installer works ....  or doesn't work (such as in this case).

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: 403 and 'undefined' errors in my install

by Laurent Duperval -
HI Ken,

Thank you for your detailed reply. I had the same question as you regarding the installation using SG's tools. The reply was that they tested on their end and found no problem.

I can confirm that it was the case for me also, but then something happened that messed things up.

This morning, I tried enrolling a new user and I realized that the problem is even worse than I thought. The new user does not get inserted in the database correctly. Although his profile is there, he does not have a role assigned, I can't edit his role to give him a Student role. When I edit his profile it says "This user does not have any role assignments anywhere in this site."

When I go to the course and click the "Enrol" button, nothing happens. Once in a while I get an Undefined error. I tried from different devices. The undefined error also happenes to people who are in a different geographical region.

It's looking more and more like I will have to reinstall everything.

The SOS links all work except the phpinfo link which shows a blank page.

I will try to get access to the command line to debug further.

L
In reply to Laurent Duperval

Re: 403 and 'undefined' errors in my install

by Ken Task -
Picture of Particularly helpful Moodlers

"The reply was that they tested on their end and found no problem"

Tested on your site or some other?   Obviously, didn't work for you! :|

"I can confirm that it was the case for me also, but then something happened that messed things up"

Then why are you getting access denied errors?

The SOS page link is correct and shouldn't produce a blank page.  Fact that it goes to php info is a major boo-boo.   Something else you could do ... create a phpinfo page of your own and put it at code root.   Don't have to login to see that.  Now if that also poduces blank page - check server error logs.   Surely you site is keeping those!

Strongly suggest adding debug lines from config-dist.php file into your config.php file to get more info when you do anything that's broken.

And let's hope you don't have to re-install.    Does that app do a site backup prior to it's attempt to upgrade?    If you have a backup of the site, can you restore the backup?

Do you have a file browser in SG panel?   Have you looked at files/folders in your moodle code to see what ownerships/permissions they currently have?

'SoS', Ken

In reply to Ken Task

Re: 403 and 'undefined' errors in my install

by Laurent Duperval -
php -v

PHP 7.4.33 (cli) (built: Mar 29 2024 11:14:50) ( ZTS )

Php -m

[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
enchant
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
imap
intl
json
libxml
mbstring
memcached
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
pspell
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
tidy
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

config.php is owned by my user and permissions ar 644

All files in the system seem to be owned by me and have 644 or 755 ownership. I don't know the exact find command to use to find the ones that don't. I'll look it up.
In reply to Laurent Duperval

Re: 403 and 'undefined' errors in my install

by Ken Task -
Picture of Particularly helpful Moodlers

php vr. 7.4.x is fine for Moodle 4.1.highest, but not for any version of moodle higher than 4.1.  Minimum is 8.0 of PHP.

It appears you have all the required PHP extensions.

See the chart:

http://www.syndrega.ch/blog/#php-and-dbms-compatibility-of-major-moodle-releases

All higher versions of moodle have a minimum of php 8.0.

So the App wasn't smart enough to realize that and upgrade your php before attempting upgrade to moodle.

That's fixable.

'SoS', Ken

In reply to Ken Task

Re: 403 and 'undefined' errors in my install

by Laurent Duperval -
My Moodle version is 4.1.9. I'm assuming it's the version they install by default because it matches the PHP level. In the notifications area, it says 4.1.10 is available but I did not update. I thought it was best to use whatever version was installed with by their tools and not to mess with it too much.

BTW, I never tried to upgrade anything. I did a default install. Ièm wondering if a plugin that is no longer active might have caused the problem. I now I tried to install the stripe payment gateway and it didn't work. I had also installed the MFA plugin but never configured it fully. The site was working with both of those plugins installed. When I started getting the undefined errors I uninstalled them, just to make sure. I also uninstalled som language packs (fr and fr_ca) in case that was the problem. But in both cases, nothing changed.

I eventually reinstalled the language packs but I did not reinstall the plugins.

So now, is there a way for me to check the status of the database? I'm beginning to suspect that it might be the problem, simply because the new user is not added as a student in the system. I checked and he is considered an authenticated user, but I can't add him to the correct role. So is it possible that there is some corruption in the database? If so, is there a way to do a healthcheck of the DB's content?

Thanks!
In reply to Laurent Duperval

Re: 403 and 'undefined' errors in my install

by Ken Task -
Picture of Particularly helpful Moodlers

Think it would help if you could turn on debugging - all the way to developer level.

'healthcheck' ... there is a script in admin/cli/ called check_database_schema.php

No options ... so one doesn't need to think ... just issue:

php check_database_schema.php [ENTER]

Any script in admin/cli/ will read config.php for variables it might need to execute.

What it might find may not be fixable via Moodle Admin interface - DB client only and could require superuser creds for your DB server ... which providers usually hide from customers as one could do a lot of damage.

Actually, dirty little secret, your setup may not have a user that's setup with all priv's to the DB if on a VPS.

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: 403 and 'undefined' errors in my install

by Laurent Duperval -
I finally found the problem! Well, the SG team did.

The culprit was a WordPress security plugin (all-in-one wp security) which blocked anything with the word "password" or "config" in it. I suspect there might have been a mess up from the web dev team, or an automatic update that caused it. The SG team said they deactivated it and things started working. Then they reactivated it and things were still working.

And indeed, my Moodle setup is now working even though that plugin is active. If it happens again, at least I know where to look.

Thanks a lot for your help, Ken! It forced me to keep pushing until it worked.

L
In reply to Laurent Duperval

Re: 403 and 'undefined' errors in my install

by Ken Task -
Picture of Particularly helpful Moodlers

Well, congrats!  

"culprit was a WordPress security plugin (all-in-one wp security)"

For others who host with SG this is handy info to know.  Now that begs a question ... where is your moodle code in relation to the WordPress code?

Think I'd still run that schema script to see if there has been any 'damage' to Moodle DB.

And ... think I'd still pursue the use of Git for your Moodle since you do have CLI.

'SoS', Ken