Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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 CreditAttribution: fortis as a volunteer commentedComment #3
fortis CreditAttribution: fortis as a volunteer commentedComment #4
bwaindwain CreditAttribution: bwaindwain as a volunteer 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 CreditAttribution: 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 CreditAttribution: Graber as a volunteer commentedLooks good, bumping priority because of #5. RTBC for me.
Comment #8
mcdruidComment #9
mcdruidNoting 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_info
may 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 CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commented+1
Comment #12
mcdruidThank you!