I got this during install of the latest 8.x version of Spark:

  if (!empty($langcode)) {
    $language = language_load(langcode);
  }

Oopsie. :P Fix is really simple (attached), but this means we lack test coverage.

Comments

sutharsan’s picture

Status: Needs review » Reviewed & tested by the community

Found this bug too. Nice solution ;)

catch’s picture

Status: Reviewed & tested by the community » Needs work

Still needs tests.

yesct’s picture

Assigned: Unassigned » yesct

I can do this.

yesct’s picture

I tried:
enabling ui translation
adding a language
going to the updates report and checking manually with the language in the url, for example: af/admin/reports/updates
But I'm not getting the error.

Looks like I might need to go somewhere that causes the
$text .= ' ' . t('See the <a href="@available_updates">available updates</a> page for more information and to install your missing updates.', array('@available_updates' => url('admin/reports/updates/update', array('language' => $language))), array('langcode' => $langcode));
to get used.

Comments on the function say

 * Returns the appropriate message text when site is out of date or not secure.
 *
 * These error messages are shared by both update_requirements() for the
 * site-wide status report at admin/reports/status and in the body of the
 * notification e-mail messages generated by update_cron().

Ok. So I try: af/admin/reports/status
There is no error, and also, the link is generated ok.
It's also ok for admin/reports/status

I'll try adding a contrib module.

yesct’s picture

I also tried:
dropping db tables
sudo rm -r sites; git checkout sites;
getting spark and putting it in modules
enabling the spark demo

no error, even when visiting admin/reports/status

enable ui translation
adding a language
going to af/admin/reports/status

no error.

I guess I need steps to reproduce. (there is some history of my env being different from webchick's .. and Sutharsan's)

webchick’s picture

You might need to download an older version of a contrib module?

yesct’s picture

Assigned: yesct » Unassigned
Issue tags: +Needs steps to reproduce

I wont get back to this, at least until tonight.

joates’s picture

difficult bug to recreate..
_update_message_text() is only called with a value in the 4th parameter which is $langcode from update_mail()
_update_message_text() is also called from update.install but only with 3 parameters ($langcode = NULL) and therefore empty.
(see http://api.drupal.org/api/drupal/core%21modules%21update%21update.module...)

i think this test can only be triggered by a site generated email and will only ever show up in a server log file.
using dpm($langcode) before and after the patch shows that it is _always_ NULL when $langcode is included in the URL such as YesCT's testing /af/admin/reports/status

gábor hojtsy’s picture

Hm. Somehow it does show up in Drupal 8 Spark builds on install. Except now webchick added this patch to the build there :) If you roll it back before you install, it should show up with display errrors on hopefully.

joates’s picture

Title: Notice: Use of undefined constant langcode in _update_message_text() (line 605 of update.module) » Notice: Use of undefined constant langcode in _update_message_text() (line 605 of update.module) when installing Spark.
Assigned: Unassigned » joates

amending issue title..

joates’s picture

Assigned: joates » Unassigned

i could not proceed with installing Spark profile because it depends on ckeditor but there is not an 8.x version of ckeditor in the git repo (that i can locate with my novice contribution skills, sorry)

joates’s picture

whilst i agree with webchick and Gábor that this error can be reproduced by installing Spark (because the update module is part of the install profile and the entire module file is parsed for PHP errors) i still think that the _patch_ cannot be tested (during installation) because there is only ever 1 language enabled during installation and therefore !empty($langcode) will never be TRUE ?

i assume we have to find a way to trigger the site-generated email when at least 2 languages are enabled and an enabled contrib module has a newer version available. The $langcode value should be included in the url generated when these conditions are met (or however url() is handling the $language and $langcode parameters).

joates’s picture

StatusFileSize
new50.73 KB

Test setup:

  • en is the system default language and en-gb is installed as a 2nd language.
  • i already had installed the devel module so i just edited the devel.info file to amend the version string to "8.x-0.0" as i thought this would be enough to trigger the update warnings in the email response.

i was able to generate this email message invoked from a drush script.. BEFORE applying the patch
pls see attached screenshot..

script:

#!/usr/bin/drush

  $module   = 'update';
  $key      = 'test';
  $to       = '##to_email##';  // NOTE: removed for privacy
  $langcode = 'en-gb';
  $params   = array();
  $from     = '##from_email##';  // NOTE: removed for privacy
  $send     = TRUE;

  drupal_mail($module, $key, $to, $langcode, $params, $from, $send);
  drush_print('Test email sent to ' . $to);
joates’s picture

StatusFileSize
new52.69 KB

enabled all update notifications (not only security updates)
and applied the patch..

joates@cb200:/8.x-dev$ git status -s
 M core/modules/update/update.module
 M sites/default/modules/devel/devel.info
joates@cb200:/8.x-dev$ 

and then i re-ran my drush script..

i don't think this is generating a positive test result :((
but my method may lead someone else into a more suitable way to test this?

.

gábor hojtsy’s picture

Anybody else can reproduce this?

gábor hojtsy’s picture

Nobody?

webchick’s picture

Oh. The error won't happen anymore with Spark, because Spark pulls in the patch in the OP to work around it. :P

yesct’s picture

With an old version of spark, what were the steps to produce then? Just install? Or did you have to go to a series of pages, which ones?

webchick’s picture

It's been awhile now, but yeah iirc it was just installing and then you'd see this on the final page of the installer.

It ought to be possible to reproduce this with just core though... we just need to hit that line that has the typo, and stick that in an automated test. There are pretty decent tests in http://drupalcode.org/project/drupal.git/tree/refs/heads/8.x:/core/modul... including a function refreshUpdateStatus that lets you mock whatever scenario.

Reading through http://api.drupal.org/api/drupal/core%21modules%21update%21update.module..., looks like it happens on a module where the update is one of:

case UPDATE_UNKNOWN:
case UPDATE_NOT_CHECKED:
case UPDATE_NOT_FETCHED:
case UPDATE_FETCH_PENDING:

and the $langcode argument to that function is populated.

zetagraph’s picture

No error for me. Tried to reproduce on a clean Spark distribution local install

Steps Taken:

  • enabling the spark demo
  • adding a language
  • going to fr/admin/reports/status
  • no error on admin/reports/status
dsnopek’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new20.02 KB

For me this happens during a standard install of the latest Drupal 8.x:

Selection_053.png

However, this is clearly a type-o! It's using the bare word 'langcode' as if it were a constant, however, no constant is defined so it's actually passing the string 'langcode' to that function everytime. Which isn't correct.

This patch fixes the problem for me!

dsnopek’s picture

Title: Notice: Use of undefined constant langcode in _update_message_text() (line 605 of update.module) when installing Spark. » Notice: Use of undefined constant langcode in _update_message_text() (line 605 of update.module) when installing Drupal 8.x

This affects Drupal 8.x, not just Spark.

webchick’s picture

Title: Notice: Use of undefined constant langcode in _update_message_text() (line 605 of update.module) when installing Drupal 8.x » Need tests for _update_message_text()
Status: Reviewed & tested by the community » Needs work

All right, I guess I'll go ahead and commit this then, since it's unlikely we make the same mistake again, but I'm leaving needs work because it's clear this portion of the code has zero test coverage.

Committed and pushed to 8.x. Heh, I totally forgot this was my patch. :P

jair’s picture

Issue tags: +Needs reroll
alansaviolobo’s picture

Issue summary: View changes
Issue tags: -Needs steps to reproduce, -Needs reroll

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • webchick committed 219ec3c on 8.3.x
    Issue #1793042 by webchick: Fixed Notice: Use of undefined constant...

  • webchick committed 219ec3c on 8.3.x
    Issue #1793042 by webchick: Fixed Notice: Use of undefined constant...

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • webchick committed 219ec3c on 8.4.x
    Issue #1793042 by webchick: Fixed Notice: Use of undefined constant...

  • webchick committed 219ec3c on 8.4.x
    Issue #1793042 by webchick: Fixed Notice: Use of undefined constant...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

catch’s picture

Status: Needs work » Fixed
Issue tags: +Bug Smash Initiative

This was committed in 2013. If we still need to add test coverage it should happen in a follow-up task.

Status: Fixed » Closed (fixed)

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