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',
  );
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fortis created an issue. See original summary.

fortis’s picture

Issue summary: View changes
bwaindwain’s picture

Thanks 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.

interdruper’s picture

This error is triggered whenever module_disable() is used (in our case, using the Habitat module). Under PHP 7.2 the warnings are:

Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_URL - assumed               [warning]
'LOCALE_LANGUAGE_NEGOTIATION_URL' (this will throw an Error in a future version of
PHP) locale.module:570
Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_SESSION - assumed           [warning]
'LOCALE_LANGUAGE_NEGOTIATION_SESSION' (this will throw an Error in a future
version of PHP) locale.module:584
Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_USER - assumed              [warning]
'LOCALE_LANGUAGE_NEGOTIATION_USER' (this will throw an Error in a future version
of PHP) locale.module:597
Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_BROWSER - assumed           [warning]
'LOCALE_LANGUAGE_NEGOTIATION_BROWSER' (this will throw an Error in a future
version of PHP) locale.module:605
Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_INTERFACE - assumed         [warning]
'LOCALE_LANGUAGE_NEGOTIATION_INTERFACE' (this will throw an Error in a future
version of PHP) locale.module:614
Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK - assumed      [warning]
'LOCALE_LANGUAGE_NEGOTIATION_URL_FALLBACK' (this will throw an Error in a future
version of PHP) locale.module:623

Note that in the next major version of PHP, an Error exception will be thrown instead.

Liam Morland’s picture

Patch looks good. Tests pass.

Graber’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

Looks good, bumping priority because of #5. RTBC for me.

mcdruid’s picture

Issue tags: +Drupal 7 bugfix target
mcdruid’s picture

Noting that locale_init() includes the file:

function locale_init() {
  global $conf, $language;
  include_once DRUPAL_ROOT . '/includes/locale.inc';

...but a couple of other functions / hooks within the module also seem to need to do their own include/require, e.g.:

function locale_js_alter(&$javascript) {
  global $language;

  $dir = 'public://' . variable_get('locale_js_directory', 'languages');
  $parsed = variable_get('javascript_parsed', array());
  $files = $new_files = FALSE;

  // Require because locale_js_alter() could be called without locale_init().
  require_once DRUPAL_ROOT . '/includes/locale.inc';

It makes sense that hook_language_negotiation_info may be invoked before hook_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).

Fabianx’s picture

+1

  • mcdruid committed 12829d8 on 7.x
    Issue #2571711 by fortis, interdruper, bwaindwain, Liam Morland, Graber...
mcdruid’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Drupal 7 bugfix target

Thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.