Cannot redeclare get_roles_with_assignment_on_context()

Cannot redeclare get_roles_with_assignment_on_context()

by W. Schouten -
Number of replies: 3

After this week's recent upgrade from 3.5.3 to 3.6.2, the hosting provider informed me about the following fatal error:  

[pid [2920676|tel:2920676]] writev(6, [{"LS\6\0\n\1\0\0", 8},

{"PHP Fatal error: Cannot redeclare get_roles_with_assignment_on_context() (previously declared in public_html/lib/accesslib.php:4101|http://famschouten.eu/public_html/lib/accesslib.php:4101]) in public_html/lib/deprecatedlib.php|http://famschouten.eu/public_html/lib/deprecatedlib.php] on line 3452\n", 258}

 ], 2) = 266

The previous version was running fine (not aware of warnings nor errors) and this week's upgrade was executed automatically by Installatron Applications Installer. 

Do you have any suggestion to fix this error? The site is totally blank as a result of this error. Thank you very much!


Average of ratings: -
In reply to W. Schouten

Re: Cannot redeclare get_roles_with_assignment_on_context()

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Here is line 4101 from lib/accesslib.php in Moodle 3.6.2

https://github.com/moodle/moodle/blob/v3.6.2/lib/accesslib.php#L4101

It is NOT a declaration of function get_roles_with_assignment_on_context() as your error claims. 

However, if you look at lib/accesslib from 3.5.3...

https://github.com/moodle/moodle/blob/v3.5.3/lib/accesslib.php#L4101

...there is the offending declaration!

Conclusion - you have upgraded some files but not others. I don't know what you have done but you clearly have now got a mix of 3.5.3 and 3.6.2 files. It might just be accesslib.php but who knows?

The sensible thing to do is to completely replace the code with a fresh download of 3.6.2

Average of ratings: Useful (1)
In reply to Howard Miller

Re: Cannot redeclare get_roles_with_assignment_on_context()

by W. Schouten -

Thank you for your reaction Howard. I can't explain the mix of 3.5.3 en 3.6.2 as I'm using Installatron to manage the Moodle-installation. Last week, I've received a message about the successful upgrade of Moodle but as you've read the message above, that was definitely not the case.

Ater your reaction, I've asked the hosting provider to return a backup from 2 weeks ago. This action is in the meantime succesfully finished. As a result, 3.5.3 is currently installed and the option (within Installatron) to update to 3.6.2 is visible again.

Prior to updating Moodle from Installatron I want to ask you this question: Do you recommend using Installatron to manage the Moodle-installation?

In reply to W. Schouten

Re: Cannot redeclare get_roles_with_assignment_on_context()

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Easy - no!!

I never recommend using these installers because THIS is what happens.