Affects Version/s: 3.11
Fix Version/s: None
Component/s: Unit tests
When I try to run the Moodle unit tests, it seems like every unit test that creates a test user fails for me with this error (originating test case file and line will change depending on the unit test, of course):
Setting $CFG->country in the config.php file seems to have no effect on the error.
I'm running the unit tests on CentOS 7.9 with PHP 7.4.18 and MariaDB 10.3.27.
The apparent cause is that $CFG->country is not defined in the unit tests, and the lib/classes/user.php method fill_properties_cache() uses the value without checking that it is actually set on line 677.
I checked the unit testing config table (phpu_config) and it does not contain a value for country (mdl_config does).
Note: This error does not appear to be new for Moodle 3.11, I have seen a nearly identical error on Moodle 3.7 (PHP 7.1.29) (same error, different line number). Strangely, the error does not occur on my Moodle 3.9 test server (PHP 7.2.31).
The primary difference appears to be that the Moodle 3.9 site actually puts a value for country into the unit test config table. I do not yet know why the Moodle 3.7 and Moodle 3.11 sites do not create a country value in the unit test config table.