Capability 'moodle/blog:associatemodule' was not found!

Capability 'moodle/blog:associatemodule' was not found!

by Susan Fleming -
Number of replies: 8

We recently upgraded from Moodle 3.5.3 to Moodle 3.5.5 (Build: 20190311) and implemented the Adaptable theme.  Since upgrading to 3.5.5, we have been encountering this error  when restoring some, but not all of our courses:

restore error message

We know that the problem is not theme related because we have tried both More and Clean with the same results.  We have uninstalled the blog plugins, since they don't appear to be supported any more and no one at our institution is using them; we have also disabled the blog settings in Site Admin:

site blog settings

site blog settings


When we restore with debugging turned on, we get the following:

Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.
  • line 3594 of /lib/deprecatedlib.php: call to debugging()
  • line 3872 of /lib/deprecatedlib.php: call to events_dispatch()
  • line 839 of /lib/classes/event/base.php: call to events_trigger_legacy()
  • line 4925 of /lib/moodlelib.php: call to core\event\base->trigger()
  • line 238 of /backup/util/ui/restore_ui.class.php: call to delete_course()
  • line 144 of /backup/restore.php: call to restore_ui->cleanup()

Coding error detected, it must be fixed by a programmer: Capability 'moodle/blog:associatemodule' was not found! This has to be fixed in code.

More information about this error

Debug info:
Error code: codingerror
Stack trace:
  • line 1314 of /lib/accesslib.php: coding_exception thrown
  • line 2098 of /backup/moodle2/restore_stepslib.php: call to assign_capability()
  • line 137 of /backup/util/plan/restore_structure_step.class.php: call to restore_ras_and_caps_structure_step->process_override()
  • line 112 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
  • line 178 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
  • line 100 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
  • line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
  • line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
  • line 190 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
  • line 278 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
  • line ? of unknownfile: call to progressive_parser->end_tag()
  • line 179 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
  • line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
  • line 110 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
  • line 181 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
  • line 210 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()
  • line 178 of /backup/util/plan/base_plan.class.php: call to restore_activity_task->execute()
  • line 168 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
  • line 339 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
  • line 224 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
  • line 135 of /backup/restore.php: call to restore_ui->execute()


We have access to a basic (unconfigured) 3.7 Moodle instance and have been able to restore at least one course there, back it up, then successfully restore it without user data on our 3.5.5 site.  There are privacy issues related to using the 3.7 site along with the logistics of having to do this with multiple courses. 

Any help would be greatly appreciated.

Average of ratings: -
In reply to Susan Fleming

Re: Capability 'moodle/blog:associatemodule' was not found!

by Ken Task -
Picture of Particularly helpful Moodlers

"We have uninstalled the blog plugins" ... the core blog plugin or
an addon blog plugin ... or both?

3.5 is now 3.5.7.
Moodle 3.5.6 13 May 2019 and was the last point release
in that version for bug fixes in code: Bug fixes for general core bugs in 3.5.x ended May 2019 (12 months)

If you have a clone of production server that is set up just like production, suggest updating the clone to 3.5.6 first then see if the issue persist.

That update on your dev box (the clone) will probably restore the core blog plugin deleted.  But that's OK.  Just hide core plugins. if you do not want to use them  (don't delete).

If programmers of moodle were still fixing 3.5.x you might have discovered a conditional bug (only happens when deleting core blog), but ... even then, response to tracker posting might be ... not a bug ... with recommendation to just hide blog plugin. smile

There was no upgrade to php at the same time, was there?  If so, what version of PHP?

'SoS', Ken

In reply to Susan Fleming

Re: Capability 'moodle/blog:associatemodule' was not found!

by Paul Raper -

I have a similar problem. I got the coding error message first, but then after the Cron ran, I got a second message. Unfortubnately I am not able to access the users section of Moodle.

I'm using Moodle 3.7+ and it is a fresh installation.

My server is Ubuntu Linux.

Attachment Codding Error Moodle.png
Attachment Moodle Error.png
In reply to Paul Raper

Re: Capability 'moodle/blog:associatemodule' was not found!

by Paul Raper -

I fixed the issue by installing the latest version of the application.

Now it works again perfectly.

In reply to Paul Raper

Re: Capability 'moodle/blog:associatemodule' was not found!

by Susan Fleming -
Hello Paul

We haven't been able to identify the specific application. Which one did you update?
In reply to Susan Fleming

Re: Capability 'moodle/blog:associatemodule' was not found!

by Paul Raper -
The whole Moodle application. So, if I was running 3.7+ originally, I have now updated to 3.7.1+.

In the course of doing that, the problem seems to have fixed itself.

Clearly I'm not able to determine whether or not the code in the original version became corrupted, and by now installing the new version that fixed it, or whether the database table became corrupted, and in the process of refreshing all of the data the problem fixed itself. Either way it worked.
In reply to Susan Fleming

Re: Capability 'moodle/blog:associatemodule' was not found!

by Yerko Zuñiga -
Same problem here in moodle 3.5.8+, when restoring a course.


This capability was removed on moodle 3.1, so why it appears in upper versions?

this capability does not come in DB table "capabilities", but when you query  "role_capabilities"  table, you might found registers with "moodle/blog:associatemodule" in capability column, then those registers had to be inherited from older versions (pre moodle 3.1).
So to fix that issue, you can delete registers from "role_capabilities" table filtering by capability='moodle/blog:associatemodule'  and validate those contextid doesn't exists in "context" DB table.

Yerko Zúñiga
In reply to Yerko Zuñiga

Re: Capability 'moodle/blog:associatemodule' was not found!

by Susan Fleming -
Hi Yerko,

Thank you for your Help!!! I have a question for you.. What if the contextid exists in the "context" DB table? Do I delete them as well after I deleted the capability = moodle/blog:associatemodule fields from role_capabilities to make sure that those fields do not exist in the Context DB?

Regards,
COTROnline Team.
In reply to Susan Fleming

Re: Capability 'moodle/blog:associatemodule' was not found!

by Yerko Zuñiga -
Hi Susan,
I think you can delete records in the role_capabilities table even if they exist in the context table, because this capability no longer exists in moodle from 3.1, anyway this capability will not be used in the context association, you should not delete the records from the table context because this can refer to some module or course.
In our case those contexts no longer existed, maybe module or course had been deleted.

Regards
Yerko Zúñiga
Mindfree Ingeniería