Cannot add functions to service

Cannot add functions to service

by Son TRAN -
Number of replies: 1

Dear All,

I just reinstalled Moodle version 3.8.1 build 20200113. Everything seems OK. But when I tried to add some functions to the Moodle mobile web service, I got the the following Error

"Coding error detected, it must be fixed by a programmer: Cannot find file with external function implementation" 

The link to API Documentations gave me the same error message.

So did I miss some files during the installation?

Many thanks


Average of ratings: -
In reply to Son TRAN

Re: Cannot add functions to service

by John Doyle -
Have also run into this error.  Found it occurring when a plugin declares a web service function in /db/services.php and the classpath parameter - which should be the path to the externallib.php file - is not the correct path.  This can happen after updating plugin names/paths or if externallib.php is in an unusual location.

The error doesn't currently specify which plugin is the culprit, but have been able to narrow down with a couple steps:

1) Get a list of all the actual externallib.php paths  - e.g. here's a quick command: 

find . -name "externallib.php"

2) Compare the paths in (1) with the classpath values in the mdl_external_functions DB table. Suggest starting with custom or 3rd-party plugins, they are far more likely suspects than core. There should be one or more paths that do not match; those are the ones where you'll then want to update the classpath parameter in /db/services.php.

Also previously encountered a similar/related error, "Cannot find external class".  Noticed this occurred because the web service class name or other parameters were updated in an existing plugin, but the version was not bumped in version.php, so the mdl_external_functions table in the DB had outdated information for classname/path/etc. Solution in that case was to bump the plugin minor version number - e.g. from 2020061800 to 2020061801.

Hope you got it solved!