admin cannot log in after upgrade from 1.9 to 2.2

Re: admin cannot log in after upgrade from 1.9 to 2.2

by Leon Stringer -
Number of replies: 0
Picture of Core developers Picture of Particularly helpful Moodlers

Hi,
 
I got the "Cannot access empty property in /var/www/html/moodle22+/moodle/enrol/database/lib.php on line 99" error on upgrade from 1.9.19 to 2.2.6.
 
It looks like this is because our enrol_localrolefield has an empty value in mdl_config_plugins. Even though this field is optional (according to http://docs.moodle.org/25/en/External_database_enrolment), enrol/database/lib.php appears to assume this will have a value.
 
I had to change lines 98-100 of enrol/database/lib.php to:
        if ($localrolefield) {
            foreach ($allroles as $role) {
                $roles[$role->$localrolefield] = $role->id;
            }
        }
(i.e. adding the if () block) which appeared to work for me. I realise 2.2.6 is unsupported but it looks like this is still an issue in Moodle 2.5. I can't test it as I'm stuck with an older MySQL version so I can't raise a bug for this issue (as 2.2.6 doesn't appear in the tracker). I thought I'd post this in case it helps anyone else.
 
Leon