error when adding external functions to a web service.

error when adding external functions to a web service.

by RK B -
Number of replies: 14

When I try to add external functions to a web service.

I get these errors.

Can anyone direct me about what this error/s is about.

Any plugin that is missing or some missing files



Coding error detected, it must be fixed by a programmer: Cannot find file with external function implementation
    line 87 of /lib/externallib.php: coding_exception thrown
    line 199 of /admin/webservice/forms.php: call to external_api::external_function_info()
    line 204 of /lib/formslib.php: call to external_service_functions_form->definition()
    line 60 of /admin/webservice/service_functions.php: call to moodleform->__construct()

Average of ratings: -
In reply to RK B

Re: error when adding external functions to a web service.

by Rohit Panchal -

Hi Rama,

Two files are mandatory for adding web service in our plugin.

1. db/services.php

2. externallib.php

please refer below link, it might solve your problem


https://docs.moodle.org/dev/External_services_description


Thanks

Rohit Panchal

In reply to Rohit Panchal

Re: error when adding external functions to a web service.

by RK B -

Thank you Rohit for the suggestion.  I was trying to connect my WP site to Moodle and faced this issue.

I used the brute force technique of cleaning up all my plugins which were not being used and especially those which showed some warnings like missing files.

After this cleanup this issue got resolved. I am not sure which plugin was causing the issue but could be from a theme.


Thanks Again.


Regards


Rama


In reply to RK B

Re: error when adding external functions to a web service.

by sadaf sadafian -
Hi
There is no need to using "brute force" algorithm to find issue!
You can find it in O(1) !
just add this code after line 87 (in if scope):
print_r($function);
after refreshing page that Error occurred, you should see something like this:
stdClass Object ( 
    [id] => `int id`
    [name] => `name of service that has the problem`
    [classname] => `classname of service that has the problem`
    [methodname] => `name of method that has the problem (in externallib.php)`
    [classpath] => `the path of file that has the problem`
    [component] => `name of plugin`
    [services] => `some services`
)
Average of ratings: Useful (1)
In reply to sadaf sadafian

Re: error when adding external functions to a web service.

by Felipe Reis -
Hi Sadaf,
Your comment saved my life! Thank you... with that line I found the plugin!
Regards!
In reply to sadaf sadafian

Re: error when adding external functions to a web service.

by Erik Pérez -
This worked for me thanks. Identify buggy plugins and fix them
In reply to Rohit Panchal

Re: error when adding external functions to a web service.

by Madhukar Reddy -

HI, 


i got the same issue after upgrading to moodle 3.6, 


here is my debug message :


line 87 of /lib/externallib.php: coding_exception thrown

 line 199 of /admin/webservice/forms.php: call to external_api::external_function_info()

 line 204 of /lib/formslib.php: call to external_service_functions_form->definition()

 line 60 of /admin/webservice/service_functions.php: call to moodleform->__construct()


Can you please suggest me solution


Thanks in advance,


Regards,

Madhukar

In reply to RK B

Re: error when adding external functions to a web service.

by Eswar sfc -

Hi Rama,


upgrade joomdle plugin,in your plugins tab(using administrator login),then it works.


Thanks

In reply to RK B

Re: error when adding external functions to a web service.

by Artur Welp -

This is one of the most difficult error to debug in my opinion.

The code now, fully stop the execution. I think this should not be a fatal error.


In a emergency, you can add a return before moodle throw a error.

In the file /lib/externallib.php line 87.

if (!file_exists($function->classpath)) {
return;
throw new coding_exception('Cannot find file with external function implementation');
}

Average of ratings: Useful (2)
In reply to Artur Welp

Re: error when adding external functions to a web service.

by Andrew Normore -
Can confirm this hack has gotten me by.
In reply to RK B

Re: error when adding external functions to a web service.

by Giannis Theodoulou -

Same error here, fresh installation, all plugins working and up to date

Any ideas?

In reply to RK B

Re: error when adding external functions to a web service.

by Adam Barker -

I managed to solve this on my install.

I manage a version of Moodle that has been updated and modified a lot across the years, so was created a long time ago and upgraded a fair few times. 

The issue in my case was a knock on of have the database reference to an old disabled theme. Deleting these themes through the plugin manager resolved this issue.

In reply to RK B

Re: error when adding external functions to a web service.

by Richard van Iwaarden -
Picture of Particularly helpful Moodlers
I ran into the same issue today. It seems that installing plugins en removing plugins leaves traces in /admin/webservice/documentation.php? for example.

Where do these traces come from and how to delete them? I tried searching the database but it didn't came up with references?