there is installation notices in locale.module
Notice: Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_URL - assumed 'LOCALE_LANGUAGE_NEGOTIATION_URL' in locale_language_negotiation_info() (line 570 of /modules/locale/locale.module).
Notice: Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_SESSION - assumed 'LOCALE_LANGUAGE_NEGOTIATION_SESSION' in locale_language_negotiation_info() (line 584 of /modules/locale/locale.module).
Notice: Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_USER - assumed 'LOCALE_LANGUAGE_NEGOTIATION_USER' in locale_language_negotiation_info() (line 597 of /modules/locale/locale.module).
Notice: Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_BROWSER - assumed 'LOCALE_LANGUAGE_NEGOTIATION_BROWSER' in locale_language_negotiation_info() (line 605 of /modules/locale/locale.module).
Notice: Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_INTERFACE - assumed 'LOCALE_LANGUAGE_NEGOTIATION_INTERFACE' in locale_language_negotiation_info() (line 614 of /modules/locale/locale.module).
Notice: Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK - assumed 'LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK' in locale_language_negotiation_info() (line 623 of /modules/locale/locale.module).
constants have been moved into locale.inc (https://www.drupal.org/node/780318), so we should require it in locale_language_negotiation_info()
function locale_language_negotiation_info() {
+ require_once DRUPAL_ROOT . '/includes/locale.inc';
$file = 'includes/locale.inc';
$providers = array();
$providers[LOCALE_LANGUAGE_NEGOTIATION_URL] = array(
'types' => array(LANGUAGE_TYPE_CONTENT, LANGUAGE_TYPE_INTERFACE, LANGUAGE_TYPE_URL),
'callbacks' => array(
'language' => 'locale_language_from_url',
'switcher' => 'locale_language_switcher_url',
'url_rewrite' => 'locale_language_url_rewrite_url',
),
'file' => $file,
'weight' => -8,
'name' => t('URL'),
'description' => t('Determine the language from the URL (Path prefix or domain).'),
'config' => 'admin/config/regional/language/configure/url',
);
Comments
Comment #2
fortis commentedComment #3
fortis commentedComment #4
bwaindwain commentedThanks for the fix @fortis. This fixes it for us.
To trigger this issue:
1- Enable locale module
2- Disable locale module
3- Enable locale module again and you'll see the notices.
Another symptom of this bug: When disabling a module with module_disable() our language negotiation config was getting reset. Locale module picks up the module_disable() event and fires language_types_set() and language_negotiation_purge(). Patch #3 fixes it for us.
Comment #5
interdruper commentedThis error is triggered whenever module_disable() is used (in our case, using the Habitat module). Under PHP 7.2 the warnings are:
Note that in the next major version of PHP, an Error exception will be thrown instead.
Comment #6
liam morlandPatch looks good. Tests pass.
Comment #7
graber commentedLooks good, bumping priority because of #5. RTBC for me.
Comment #8
mcdruid commentedComment #9
mcdruid commentedNoting that
locale_init()includes the file:...but a couple of other functions / hooks within the module also seem to need to do their own include/require, e.g.:
It makes sense that
hook_language_negotiation_infomay be invoked beforehook_init(where the latter is part of the last stage of Drupal's bootstrap whereas the former is part of the penultimate stage).If the file has already been parsed, no harm done other than a nominal performance cost.
So this LGTM (could add a simple comment before the
require_once()similar to the example above, but that could be done on commit).Comment #10
fabianx commented+1
Comment #12
mcdruid commentedThank you!