global $language should be an object, not a string
In file civicrm/CRM/Utils/System/Backdrop.php, in function setUFLocale()
, the global variables $language
is set this way:
global $language;
$langcode = substr($civicrm_language, 0, 2);
$languages = language_list(FALSE, TRUE);
if (isset($languages[$langcode])) {
$language = $languages[$langcode];
...
Per https://docs.backdropcms.org/api/backdrop/core%21includes%21bootstrap.inc/function/language_list/1, the call language_list(FALSE, TRUE)
returns a list whose values are strings, not objects. (For example, "English".)
However, Backdrop CMS expects $language
to be an object, as can be seen in numerous places, for example, function entity_get_info()
:
function entity_get_info($entity_type = NULL) {
global $language;
// Use the advanced backdrop_static() pattern, since this is called very often.
static $backdrop_static_fast;
if (!isset($backdrop_static_fast)) {
$backdrop_static_fast['entity_info'] = &backdrop_static(__FUNCTION__);
}
$entity_info = &$backdrop_static_fast['entity_info'];
// hook_entity_info() includes translated strings, so each language is cached
// separately.
$langcode = $language->langcode;
...
So whenever a CiviCRM page calls a function that uses one of these, it puts one (or a slew) of bad index warnings into the dblog, like this:
Notice: Trying to get property 'langcode' of non-object in entity_get_info() (line 331 of /mysite/core/modules/entity/entity.module).
The solution is to replace the call to language_list()
with
$languages = language_list();
This fixes the issue and eliminates the dblog warnings.