Posts

Latest nightmare

So here's my latest nightmare on Moodle. 1. It requires multiple upgrade steps to upgrade ONE instance. 2. My end-users have never  upgraded and are still on 3.8.4. I have about 30 instances, or thereabouts. 3. I was forced to  upgrade my server OS which upgraded PHP to version 8. 4. This broke Moodle 3.8.4 because apparently it is unacceptable to not have a questionmark before declaring a nullable return variable?!?! I mean really. This: (or something like it) is apparently NO! BAD!      myfunction(type varname = null) apparently we have to now      myfunction(?type varname = null) OK. right. Because who cares. Anyway point is there are about 10 000 of these in Moodle. Plus it also doesn't like the [\#Something] syntax. You have to delete about 2000 of those and pray it works. The alternative, in my case, is manually upgrade each instance, like 3.8.4 -> 3.8.5, 3.8.5->3.8.6 that kind of thing, all the way to 4.0.3. Because the databases diff...

breaks during database upgrade saying database table already exists

 If moodle breaks during database upgrade saying "database table already exists", you basically have no choice but to drop that table. My suggestion is to backup the database first: mysqldump moodle > moodle.sql Then use vi editor to locate that table and save that code separately. Obviously if the table is empty it doesn't matter. To find out if the table is empty, go back into mysql and type use moodle; select * from tablename; If it returns zero results, you are in luck, you can just drop the table: drop table tablename; But if it contains some stuff, then you have to save it and reload it later using mysqldump and then  mysql. Something like this: Assuming you've saved it as shown above and assuming you've kept only the SQL of that table; mysql moodle < mytablesql.sql Anyway, back on to the point. Once you have dropped the table, go back to the installer webpage, click in the URL bar where it shows the moodle webserver address, and just press Enter. Do n...

turn on debug mode moodle

 in config.php after declaration of the CFG variable: @error_reporting (E_ALL | E_STRICT); @ini_set ('display_errors', '1'); $CFG->debug = (E_ALL | E_STRICT); $CFG->debugdisplay = 1;

database text format inconsistencies

When you create the moodle database, use something like this: mysql > create database moodle collate utf8mb4_unicode_ci; And when you set up the config.php file, make sure the line "dbcollation" mentions the same text format (utf8mb4_unicode_ci). To check what text collation you used, in mysql, type: SELECT @@character_set_database, @@collation_database; If you don't do this, you might have to edit        vi /var/www/html/moodle/lib/dml/mysqli_native_moodle_database.php and change line 196 to read         $sql = "SELECT @@storage_engine engine"; instead of         $sql = "SELECT @@default_storage_engine engine";

Fix: ERROR 1396 (HY000): Operation CREATE USER failed in MySQL?

 Fix: ERROR 1396 (HY000): Operation CREATE USER failed in MySQL? This is a mysql 8 bug. Suppose the user is  myuser . 1. The user already exists. Delete them with DROP. (not DELETE).      DROP USER myuser.     DO NOT use "delete from mysql.user where user=myuser". 2. You already deleted them with DELETE. Try it again with DROP, even if they do not exist.     If you are too late and you already made the mistake in (1) above you can either create a new user with a different name, e.g. myuser2, or, repeat the drop statement above in (1). 3. The password doesn't meet the default MySQL 8 requirements.     Sometimes it is because the password isn't good enough. It must be 8 chars minimum, with at least one caps, one lower, one number, and one punctuation. 4. Check your mysql supports old passwords ( mysql_native_password).    Use  CREATE USER 'myuser'@'localhost' IDENTIFIED WITH  mysql_native_password  BY 's0m3Pas...

installing moosh to make your life easier

If your site is crashed you need to edit moodle on the command line. Enter Moosh, the moodle shell. To install moosh, do this: sudo apt-add-repository ppa:zabuch/ppa sudo apt-get update sudo apt-get install moosh Then, if you want to use moosh, you can use more or less any command shown in the web interface using a syntax of moosh -n the-command the-parameters for example cd /var/www/moodle/ moosh -n plugin-uninstall someplugin  or moosh -n cache-clear note the "cd" part - it won't work unless you do that, as it uses the config file in that directory to login. The -n part means do not ask me about my user id. Normally moodle operates as apache (www-data). Using -n lets you run it as root. Otherwise you have to do something which is in my view, worse, namely enable bash shell for apache. That opens you up to hackers, in my view, as apache is facing the web and accepts uploads on many apps such as wordpress, so it's feasible for someone to hack your server entirely if y...

Removing a troublesome plugin

Sometimes you can't login and remove a plugin because your instance crashes before the login completes. Just go to  https://yourwebsite.com/moodle/admin/plugins.php and then uninstall or disable the plugin. This URL should let you login as admin and remove plugins even if the rest of the site doesnt work (with yourwebsite.com replaced by your web address)