After Upgrade to 3.8 getting error 500

After Upgrade to 3.8 getting error 500

Dan West -
回帖数:14

Today I did an upgrade to 3.8 from 3.5.3 and had the site in maintenance mode. I was logged in as an admin, and after changing my DB type to MariaDB, did the upgrade. Everything was working fine and I was able to stay logged in to the server and add a new course. Then I turned off maintenance mode through the GUI and it refused to turn off. I went in and disabled maintenance mode then via the cli and cleared the moodledata/cache/ folder, and after that point I have not been able to get back into the server. When I try to hit the login page I get an error 500. Checking the error_log file I see an entry:

[06-Jan-2020 05:32:16 UTC] PHP Warning:  require_once(/home/packethe/public_html/cache/lib.php): failed to open stream: No such file or directory in /home/packethe/public_html/lib/setup.php on line 541
[06-Jan-2020 05:32:16 UTC] PHP Fatal error:  require_once(): Failed opening required '/home/packethe/public_html/cache/lib.php' (include_path='/home/packethe/public_html/lib/pear:.:/opt/cpanel/ea-php72/root/usr/share/pear') in /home/packethe/public_html/lib/setup.php on line 541

I have replaced the lib.php with a copy of that file but am still getting the error. I'm not sure how to turn on debug mode in moodle via CLI (or if you can), or what other info I should be looking for or should provide. I'm new to web servers and am thankful for any help or thoughts anybody might have. Thanks again in advance.

回复Dan West

Re: After Upgrade to 3.8 getting error 500

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
There's nothing in line 541 on lib/setup.php (or anywhere around it) that tries to load cache/lib.php. So... what is at and around 541 on your version. For reference, this is the line in the latest version of 3.8 (a blank line!)

https://github.com/moodle/moodle/blob/MOODLE_38_STABLE/lib/setup.php#L541
回复Howard Miller

Re: After Upgrade to 3.8 getting error 500

Dan West -
Here is my setuplib.php file starting on line 522, and bold italicized is line 541:
// Load up standard libraries
require_once($CFG->libdir .'/filterlib.php'); // Functions for filtering test as it is output
require_once($CFG->libdir .'/ajax/ajaxlib.php'); // Functions for managing our use of JavaScript and YUI
require_once($CFG->libdir .'/weblib.php'); // Functions relating to HTTP and content
require_once($CFG->libdir .'/outputlib.php'); // Functions for generating output
require_once($CFG->libdir .'/navigationlib.php'); // Class for generating Navigation structure
require_once($CFG->libdir .'/dmllib.php'); // Database access
require_once($CFG->libdir .'/datalib.php'); // Legacy lib with a big-mix of functions.
require_once($CFG->libdir .'/accesslib.php'); // Access control functions
require_once($CFG->libdir .'/deprecatedlib.php'); // Deprecated functions included for backward compatibility
require_once($CFG->libdir .'/moodlelib.php'); // Other general-purpose functions
require_once($CFG->libdir .'/enrollib.php'); // Enrolment related functions
require_once($CFG->libdir .'/pagelib.php'); // Library that defines the moodle_page class, used for $PAGE
require_once($CFG->libdir .'/blocklib.php'); // Library for controlling blocks
require_once($CFG->libdir .'/grouplib.php'); // Groups functions
require_once($CFG->libdir .'/sessionlib.php'); // All session and cookie related stuff
require_once($CFG->libdir .'/editorlib.php'); // All text editor related functions and classes
require_once($CFG->libdir .'/messagelib.php'); // Messagelib functions
require_once($CFG->libdir .'/modinfolib.php'); // Cached information on course-module instances
require_once($CFG->dirroot.'/cache/lib.php'); // Cache API
// make sure PHP is not severly misconfigured
setup_validate_php_configuration();
// Connect to the database
setup_DB();
if (PHPUNIT_TEST and !PHPUNIT_UTIL) {
// Make sure tests do not run in parallel.
$suffix = '';
if (phpunit_util::is_in_isolated_process()) {
$suffix = '.isolated';
}
test_lock::acquire('phpunit', $suffix);
$dbhash = null;
try {
if ($dbhash = $DB->get_field('config', 'value', array('name'=>'phpunittest'))) {
// reset DB tables
phpunit_util::reset_database();
}
} catch (Exception $e) {
if ($dbhash) {
// we ned to reinit if reset fails
$DB->set_field('config', 'value', 'na', array('name'=>'phpunittest'));
}
}
unset($dbhash);
}
回复Dan West

Re: After Upgrade to 3.8 getting error 500

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
Was Moodle downloaded from moodle.org (as we always recommend)?
回复Howard Miller

Re: After Upgrade to 3.8 getting error 500

Dan West -
I went to the moodle master for 3.8 and replaced those files, which finally allowed the site to run again. However now I can only get logins to work if I disable the security token in config.php.
回复Dan West

Re: After Upgrade to 3.8 getting error 500

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
Ok - but that's not what I asked you.

If there's any doubt about the provenance of the files (and I sense there is), I would strongly recommend downloading a complete Moodle install - from moodle.org - and replacing the whole lot.
回复Howard Miller

Re: After Upgrade to 3.8 getting error 500

Dan West -
Just to clarify a typo, I said "Here is my setuplib.php file starting on line 522, " but it is actually my /lib/setup.php file.
回复Dan West

Re: After Upgrade to 3.8 getting error 500

Ken Task -
Particularly helpful Moodlers的头像

This fatal error:

[06-Jan-2020 05:32:16 UTC] PHP Fatal error: require_once(): Failed opening required '/home/packethe/public_html/cache/lib.php' (include_path='/home/packethe/public_html/lib/pear:.:/opt/cpanel/ea-php72/root/usr/share/pear') in /home/packethe/public_html/lib/setup.php on line 541

indicates site is using Easy Apache which sets php version to be used for the site - php72 as per error.

Easy  Apache uses .htaccess files to accomplish setting PHP version per application.   So in your public_html folder is there an .htaccess file and if so what does it have in it?

(should have a line at the top with a warning not to edit the file from CLI cause it's created and maintained by cPanel/Easy Apache)

If it's not present, use cPanel/Easy Apache to re-set.

Easy Apache also controls what php extensions will be loaded.

'SoS', Ken

回复Ken Task

Re: After Upgrade to 3.8 getting error 500

Dan West -
Here is my full .htaccess file:
RewriteEngine on

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI) php_flag display_errors Off
php_value max_execution_time 120
php_value max_input_time 120
php_value max_input_vars 1000
php_value memory_limit 48M
php_value post_max_size 150M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php70"
php_value upload_max_filesize 128M
php_flag zlib.output_compression Off # END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language. AddType application/x-httpd-ea-php72___lsphp .php .php7 .phtml # php -- END cPanel-generated handler, do not edit
回复Dan West

Re: After Upgrade to 3.8 getting error 500

Ken Task -
Particularly helpful Moodlers的头像

The only line that looks out of place or in-correct is this one:

php_value session.save_path "/var/cpanel/php/sessions/ea-php70"

Site should be using php72 and the line above references php70 - which, according to an EasyApache reference page, should now be 'depreciated' (?) from what I understand of it! 伤心

Moodle, however, does save sessions and should be saving session files in moodledata/sessions/

Is there a sessions directory in your moodledata?  Does it contain files?  Do the files that are there have data/time stamps from accesses?

Where you host ... is it on a shared hosting environment?

Did you check server environment to see if server met environment requirements prior to attempting upgrade?

Error 500's usually indicate a server mis-config somewhere ... even if what you might find is a pointer to a moodle code file.

Also ... on some systems error files are actually kept in code directories where the error occured.  If you had command line access, I'd ask you to cd public_html where your moodle code is and then issue:

find ./ -name error_log

That would find all locations of error_log files.

One could then look at each one of them for clues! :\

Is your hosting provider helpdesk of no help?

'SoS', Ken

回复Ken Task

Re: After Upgrade to 3.8 getting error 500

Dan West -
My sessions folder does have session files in it, but all of them are date stamped before the upgrade.

My host is a VPS not shared.

When I ran the upgrade, on the moodle upgrade landing page it showed all statuses as passed, but the database had a few "check" sections relating emoji support iirc. Do I have to reconcile the checks before doing the upgrade?

There are a few of those error files:
/admin/cli/error_log, /admin/error_log, /admin/tool/dataprivacy/error_log, /course/error_log, /mod/quiz/error_log, /login/error_log, /theme/error_log, /my/error_log, /user/error_log, and ./error_log have the same error as I listed earlier (the line 541 error)
/backup/error_log only has an error from Dec 5 2019 regarding conversion path
/lib/ajax/error_log has error Dec 9 2019 creating new sessions

I've recently opened a ticket with my hosting provider to see what they will be able to help with.
回复Ken Task

Re: After Upgrade to 3.8 getting error 500

Dan West -
Ok, update of the situation, apparently I foolishly removed some important files from the wrong cache folder by being in the wrong path, and now the site is loading again after replacing them. It finished the finalizing setup steps, and I was able to login. However, after changing my theme to classic, I can't login anymore with any of my credentials. (Tried my primary and backup accounts, which worked for login before I changed the theme.) Disabling the security token via config.php allows me to login again, do i need to update my themes to allow login?
回复Dan West

Re: After Upgrade to 3.8 getting error 500

Nasasi Cown -
I had the same issue too. Found out that .htaccess file was missing.
回复Nasasi Cown

Re: After Upgrade to 3.8 getting error 500

Dan West -
I checked my server and have multiple .htaccess files currently (/moodledata and /public_html). Did you need to add it to a specific folder or did it need any specific contents?