Error about get_local_referer after upgrade

Error about get_local_referer after upgrade

by Kees Vonk -
Number of replies: 8

I have just upgraded our Moodle site from 4.0.5 to 4.3.4 and now I am getting the following error:

PHP Fatal error:  Uncaught Error: Call to undefined function get_local_referer() in /home/********.org/lib/setuplib.php:575
Stack trace:
#0 /home/*******org/lib/setuplib.php(363): get_exception_info(Object(Error))
#1 [internal function]: default_exception_handler(Object(Error))
#2 {main}
  thrown in /home/*******org/lib/setuplib.php on line 575

I performed the same upgrade to our test Moodle site on the same server, and that went without a hitch. I have done a lot of googling today, and I cannot find an answer anywhere that solves my problem.

Any help would be greatly appreciated. Our environment is like this:

  • $ uname -a
    Linux ***hostname*** 4.18.0-477.15.1.lve.2.el8.x86_64 #1 SMP Wed Aug 2 10:43:45 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
  • $php -v
    PHP 8.0.30 (cli) (built: Mar 14 2024 19:49:15) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v4.0.30, Copyright (c) Zend Technologies
        with Zend OPcache v8.0.30, Copyright (c), by Zend Technologies
  • $mysql -V
    mysql  Ver 15.1 Distrib 10.6.17-MariaDB, for Linux (x86_64) using readline 5.1
  • LiteSpeed webserver

(Edited by Mary Cooch  to remove domain name- original submission Thursday, 30 May 2024, 2:12 PM)

Average of ratings: -
In reply to Kees Vonk

Re: Error about get_local_referer after upgrade

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
get_local_referer() is defined in lib/weblib.php, which is a fundamental library file in Moodle - see https://github.com/moodle/moodle/blob/143c2cd5bef1268751d58bbfc6c66c1d93cb9797/lib/weblib.php#L230

I would start by checking that lib/weblib.php exists and the declaration for get_local_referer is to be found at (exactly) line 230.
In reply to Kees Vonk

Re: Error about get_local_referer after upgrade

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
PHP fatal errors are thrown at a lower level than the PHP code, is at the interface between PHP and the OS. How exactly do you upgrade - following https://docs.moodle.org/403/en/Upgrading ? I ask because the upgrade script goes through a set of self-checks. If both scripts went "all green" two places come to my mind: PHP and system interactions what you find under yoursite/admin/settings.php?section=systempaths or the provider has touched some PHP setting like open_basedir or disabled PHP exec(). This is a subject for your hosting service.

I assume you've eliminated the obvious like copying new source over the old or not purging all server caches.

Is that message all you get Debugging set to maximum?
Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: Error about get_local_referer after upgrade

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The error - Call to undefined function get_local_referer() in /home/ymcanorf/learning.ymcanorfolk.org/lib/setuplib.php:575 - is pretty clear. So either the function (or file it's in) is not there / corrupt or hasn't been loaded. The latter would imply a notice for failing to include lib/weblib.php. So, yes, upping Debugging (in config.php) is probably a good move.
In reply to Visvanath Ratnaweera

Re: Error about get_local_referer after upgrade

by Kees Vonk -
Thank you so much for showing me how to turn the debugging on. I found out that the problem was in the theme, and managed to fix it.
In reply to Kees Vonk

Re: Error about get_local_referer after upgrade [SOLVED]

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Glad that you could SOLVE the problem.

Generally, it is helpful to leave more information like what theme, which version, it doesn't support Moodle 4.3 or there is a newer one which does, etc. There are always others who come directly to these forums through search engines.
In reply to Visvanath Ratnaweera

Re: Error about get_local_referer after upgrade [SOLVED]

by Kees Vonk -
You are absolutely right. Thank you for reminding me.

I am using the Edumy theme (2020 version, can't find the actual version number). I had to edit the theme/edumy/classes/navigation/primary.php file and change line 79 to:
 
protected function get_primary_nav($parent = null): array {
 
(add the "$parent = null" bit between the brackets). I think I am going to have to upgrade the theme before going to Moodle 4.4.
 
BTW. I cannot find a way to mark this thread as solved.
Average of ratings: Useful (1)
In reply to Kees Vonk

Re: Error about get_local_referer after upgrade [SOLVED]

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
We don't really do "solved" but it's good to hear what you did when you find the answer. Thanks.
In reply to Kees Vonk

Re: Error about get_local_referer after upgrade [SOLVED]

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
SOLVED

We just did it together. 
wink

Read "Once your problem is solved, reply to the thread, adding [Solved] to the subject line of your post and providing links to the documentation, discussion or tracker issue that helped you." in the Code of conduct.

Either way Edumy is a commercial theme outside of the moodle.org. They provide support for their products directly.