Can’t create a new XMLDB file

The Moodle XMLDB plugin does some checks of the db/ folder in your plugin to ensure it has read/write access before allowing certain permissions (e.g. create and load). If it doesn’t find this, the text will appear but it won’t be a hyperlink. Have a look in admin/tool/xmldb/actions/main_view/main_view.class.php For example for the create button it…

Scheduled Tasks: A lock was created but not released

Schedule tasks can use two types of locks: * Database locks — lock_db table * File locks — dirroot/lock The follow error can occur when running a cron through the CLI for example: !!! Coding error detected, it must be fixed by a programmer: A lock was created but not released at: [dirroot]/lib/classes/task/manager.php on line…

Unknown Error Upgrading Plugin to Version

If you are getting an error like this when attempting to upgrade a plugin: !!! Unknown error upgrading <pluginname> to version 2017042400, can not continue. !!! !! Error code: upgradeerror !! !! Stack trace: * line 340 of /lib/upgradelib.php: upgrade_exception thrown * line 549 of /lib/upgradelib.php: call to upgrade_plugin_savepoint() * line 1630 of /lib/upgradelib.php: call…

XMLDB Editor and Reserved Names

One (of the many) good reasons to use the XMLDB editor in Moodle rather than hacking the db/install.xml file directly is that it warns you if you use a reserved name. For example: The red Reserved text after [XML] in the screenshot is indicating that the word “column” is reserved and shouldn’t be used. It…

Replacing strings in the database through the CLI

There is a tool provided with Moodle to replace strings in your database with another value. This is very useful for things such as site address or domain name changes, and changes from non-SSL (http) to SSL (https). The tool can be accessed via the following relative URL as a site administrator. /admin/tool/replace/ While you…

Resetting a user’s password through the CLI

If you have access to the Moodle server, you can use the admin/cli/reset_password.php script to reset passwords for users with the manual authentication method. To run this script (from the moodle root code directory), note you may need to sudo as a user with write privileges to the $CFG->dataroot directory. php admin/cli/reset_password.php == Password reset…

Extended characters in moodle usernames

If you need to use extended characters in usernames, there is a setting under Site Administration > Security > Site Policies called Allow extended characters in usernames extendedusernamechars. By default moodle usernames must be lowercase and are restricted to alphanumeric characters, the underscore, hypen, period and @ symbol. You don’t need this if you are…

Web service Access control exception

If you are creating or using a web service in Moodle and see the following message: { “exception”: “webservice_access_exception”, “errorcode”: “accessexception”, “message”: “Access control exception” } It can be a bit hard to troubleshoot. Generally there is a 4th item with debugging info, but this will only appear if you have the correct Moodle debugging…

Plugin is defective or outdated, Self test failed

You may see an error like this when upgrading a block: Default exception handler: Plugin “{block name}” is defective or outdated, can not continue, sorry. Debug: Self test failed. Error code: detectedbrokenplugin * line 833 of /lib/upgradelib.php: plugin_defective_exception thrown * line 425 of /lib/upgradelib.php: call to upgrade_plugins_blocks() * line 1639 of /lib/upgradelib.php: call to upgrade_plugins()…

$DB->get_record_sql only returning a single row

So you’ve written a query, passed it to $DB->get_records_sql() and, what’s this – only one row? What’s going on, where’s the rest of the query data? First off, make sure you are using the plural form (get_records_sql() and not get_record_sql()). If that’s not the issue then read on. The reason this can happen is that…

Undefined Property $webserviceprotocols

When this occurs, there is no result from a web service call and undefined property $webserviceprotocols. In the PHP error log the following appears: Undefined property: stdClass::$webserviceprotocols Check your web service protocols and ensure that the appropriate protocol is enabled. Site administration > Plugins > Web services > Manage protocols.