Updated as of #24.

Problem/Motivation

After uninstalling the locale_tamper module (or any other module) and revisiting admin/reports/translations the following notices are displayed:

Notice: Undefined index: locale_tamper in locale_translation_status_form() (line 634 of core/modules/locale/locale.pages.inc).
Notice: Trying to get property of non-object in locale_translation_status_form() (line 634 of core/modules/locale/locale.pages.inc).
Notice: Undefined index: echo in locale_translation_status_form() (line 634 of core/modules/locale/locale.pages.inc).
Notice: Trying to get property of non-object in locale_translation_status_form() (line 634 of core/modules/locale/locale.pages.inc).

When uninstalling a module before any translation is imported the below warning is displayed. Although this is an edge use case, the fix is easy.

Warning: Invalid argument supplied for foreach() in locale_translation_status_delete_projects() (line 985 of core/modules/locale/locale.module).

Proposed resolution

Check if there are any status's (it is not empty) before changing status and resaving it.

Remaining tasks

  • reproduce on current d8 head.

Steps to reproduce

based on #9

  1. install d8
  2. "install/extend" (not called enable) interface translation module under Extend
  3. add a language at admin/config/regional/language
  4. download a module, for example UI Cache Clear, https://drupal.org/node/1969588/git-instructions/8.x-1.x
  5. Add a line to the ui_cache_clear.info.yml file: project: "ui_cache_clear" (the packaging script does not yet work with D8 .info.yml files, we need this for it to know how to try and fetch the translation file for the project)
  6. install the module, on Extend, admin/modules
  7. go to admin/reports/translations, and see
        Home >>    Administration >>    Reports
    
    Available translation updates
    Add or remove shortcut
    
    Last checked: never (Check manually)
    	Language	Status
    	Afrikaans	Hide description Missing translations for 2 projects
    
        Drupal core (8.0-dev). No translation files are provided for development releases.
        UI Cache Clear (no version). File not found at http://ftp.drupal.org/files/translations/8.x/ui_cache_clear/ui_cache_clear-.af.po nor at translations://ui_cache_clear-.af.po
    
  8. check for translations manually on admin/reports/translations
  9. uninstall a module, on admin/modules/uninstall, for example: Contact
  10. reload the translations report page admin/reports/translations
  11. See error? Or no error? How many projects does it say it is missing translations for? Did it reduce from 2 to 1?)

User interface changes

none

API changes

none

Related Issues

Original Report (before disabling was removed)

After disabling a the locale_tamper module (or any other module) and revisiting admin/reports/translations the following notices are displayed:

Notice: Undefined index: locale_tamper in locale_translation_status_form() (line 634 of core/modules/locale/locale.pages.inc).
Notice: Trying to get property of non-object in locale_translation_status_form() (line 634 of core/modules/locale/locale.pages.inc).
Notice: Undefined index: echo in locale_translation_status_form() (line 634 of core/modules/locale/locale.pages.inc).
Notice: Trying to get property of non-object in locale_translation_status_form() (line 634 of core/modules/locale/locale.pages.inc).

When uninstalling a module before any translation is imported the below warning is displayed. Although this is an edge use case, the fix is easy.

Warning: Invalid argument supplied for foreach() in locale_translation_status_delete_projects() (line 985 of core/modules/locale/locale.module).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sutharsan’s picture

Status: Active » Needs review
Issue tags: +D8MI, +language-ui
FileSize
1.31 KB

The attached patch implements hook_modules_disabled() to clear the translation status when a module is disabled. This solved the php notice.
For the php warning is adds an if-condition to locale_translation_status_delete_projects() to check for existing translation status before it is removed.

Sutharsan’s picture

YesCT’s picture

Issue tags: +Novice, +Needs manual testing

tagging

docker’s picture

FileSize
34.14 KB

After the first time disabling the locale_tamper get the attached warning on the modules page.
I didn't get any message on the admin/reports/translations page.
After that I couldn't reproduce the error even If I tried to uninstall a different module or uninstall-install-disable the locale_tamper.

After a new d8 installation I've applied the #1 patch. I didn't get the warning or any other message after the first time disabling the locale_tamper. I still havent got any message after uninstalling the module.

Elijah Lynn’s picture

Status: Needs review » Needs work

Just checkout latest 8.x-dev and cannot reproduce either. Can you see if latest HEAD still has this issue?

stpaultim’s picture

Trying to recreate this issue. So far unsuccessful. Posting my steps so folks can help see if I'm missing anything:

NOTE: I was unable to try this with the "locale_tamper" module as suggested, because the "locale_tamper" module does not have .info.yml files and will not load.

1) Pulled a fresh version of Drupal 8 with GIT
2) Turn on Multilingual modules: Content Translation, Interface Translation, & Language
• Without these modules, there is no "translation" report. Even with them, it's an "Available Translation Updates" report.
3) Install Devel module
• Get AJAX HTTP error ("An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: http://drupal8:8082 ................) I am ignoring this for now, because I seem to get this error for every module I install. See: #1885788: An AJAX HTTP error occurred during module installation via UI
• Enable Devel module
4) In "Devel Settings" toggle "Display query log" - and verify that query log is working. Toggle it off again. (Just wanted to actually DO something with Devel before disabling it.
5) Disable Devel module and uninstall Devel module
• Go to Reports >> Available Translation Updates and look for error. None found.
6) Under "Available Translation Updates" Add 3 languages (German, French, & Amharic).
7) Install Backup and Migrate Module.
• Get AJAX HTTP error ("An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: http://drupal8:8082 ................) I am ignoring this for now, because I seem to get this error for every module I install. See: #1885788: An AJAX HTTP error occurred during module installation via UI
• Enable Backup and Migrate module
8) Create a QUICK BACKUP using Backup and Migrate Module - again, to actually do something with the module before disabling it.
9) Disable Backup and Migrate module.
• Go to Reports >> Available Translation Updates and look for error. None found.
10) Uninstall Backup and Migrate module.
• Go to Reports >> Available Translation Updates and look for error. None found.

=================

If anyone can suggest anything else I might do that would create this problem, let me know and I'll try again. ALSO: the reports suggested the problem occurred when "revisiting admin/reports/translations." I'm not exactly sure which report this is. I tried to recreate the error looking at the "Available translation updates" report. If I'm misunderstanding the problem, please correct me and I'll try again.

YesCT’s picture

@stpaultim is the behavior any different if you go to the translations status report while the module is on, *then* disable it and go back to the report?

robertdbailey’s picture

Status: Needs work » Closed (cannot reproduce)

@YesCT, confirmed no difference if we first visit the translation status report while the module is on and then disable the module and go back to the report. I visited the report, then enabled the XML-RPC module, then visited the report again to confirm there were no warning messages, then disabled the XML-RPC module, then visited the report again to confirm there were again no warning messages.

So, I am not able to reproduce the error, along with @Elijah Lynn and @stpaultim. Closing issue as cannot reproduce.

Sutharsan’s picture

Status: Closed (cannot reproduce) » Needs review

I can still repoduce the error, and this is how:

  • Install Drupal: English, Standard profile, MySQL database
  • Enable Language + Interface translation module
  • Enable a language: Dutch
  • Download a module: UI Cache Clear
  • Add a line to the ui_cache_clear.info.yml file: project: "ui_cache_clear" (the packaging script does not yet work with D8 .info.yml files)
  • Enable the module: admin/modules
  • Go to Available translation updates page: admin/reports/translations
  • Disable the module: admin/modules
  • Go to Available translation updates page: admin/reports/translations
  • Now you see the error:
Notice: Undefined index: ui_cache_clear in locale_translation_status_form() (line 513 of core/modules/locale/locale.pages.inc).
Notice: Trying to get property of non-object in locale_translation_status_form() (line 513 of core/modules/locale/locale.pages.inc).
nonsie’s picture

Followed the steps but was unable to replicate this error

andymartha’s picture

Followed the steps in #9 but was unable to replicate this error

jair’s picture

Issue tags: +Needs reroll

Needs Reroll

jlbellido’s picture

Rerolled with @luismagr and @neoligero , and run test.

Status: Needs review » Needs work

The last submitted patch, locale-notice-disable-module-1887136-13.patch, failed testing.

Sutharsan’s picture

+++ b/core/modules/locale/locale.module
@@ -1084,13 +1093,14 @@ function locale_translation_status_delete_languages($langcodes) {
 function locale_translation_status_delete_projects($projects) {
   $status = locale_translation_get_status();
-
-  foreach ($status as $project => $languages) {
-    if (in_array($project, $projects)) {
-      unset($status[$project]);
+  if (isset($status)) {
+    foreach ($status as $project => $languages) {
+      if (in_array($project, $projects)) {
+        unset($status[$project]);
+      }
     }
+    \Drupal::state()->set('locale.translation_status', $status);
   }
-  \Drupal::state()->set('locale.translation_status', $status);
 }

The if (isset($status)) condition will always be true. In worst case locale_translation_get_status() will return an empty array. Should be if (!empty($status)).

jlbellido’s picture

Status: Needs work » Needs review
FileSize
578 bytes
1.23 KB

Thanks @Shutharsan, sorry for that.

Status: Needs review » Needs work

The last submitted patch, locale-notice-disable-module-1887136-16.patch, failed testing.

mr.baileys’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Novice, -Needs manual testing, -Needs reroll
  • Confirmed the bug using the steps from #9
  • Manually tested and confirmed the patch from #16 fixed the issues.

The failing test seems unrelated to this patch, and passes locally, so setting to RTBC.

mr.baileys’s picture

jlbellido’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
611 bytes
842 bytes

Deleted hook_modules_disabled() because now modules can't be disabled. Thanks @Sutharsan for to advise me.

penyaskito’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC after Sutharsan requirement were fixed.

YesCT’s picture

Issue summary: View changes

in progress updating due to disabling modules broken...

YesCT’s picture

I'm updating the issue summary.

YesCT’s picture

Issue summary: View changes

fix typo and clarify

YesCT’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs manual testing
FileSize
89 KB

I cannot reproduce this.

I did notice a few things while trying to, these should be separate issues if they are not already:
1. #2034879-3: [Meta] Fix documentation that refers to enabling/disabling of modules
admin/config/regional/translate/settings
says "Check for updates of disabled modules and themes"

2. Even when my settings admin/config/regional/translate/settings says

Check for updates:
 never (manually)

When I install a module, I get a batch progress bar that says
updatingtranslations.png

I did not expect it to get the translation. I have configured to never get updates.
2a. is it really checking for the translation?
2b. is getting the initial translation different than checking for updates?

3. When installing, I get notice:
Notice: Undefined index: path in Drupal\Core\Routing\RouteBuilder->rebuild() (line 97 of core/lib/Drupal/Core/Routing/RouteBuilder.php).
Maybe because the locale module is doing something related to translating config.

YesCT’s picture

Issue summary: View changes

added steps to reproduce

YesCT’s picture

up to date summary for now.
But need someone to verify this is reproducible.

YesCT’s picture

Issue summary: View changes

updated approach.

YesCT’s picture

Issue summary: View changes

noting up to date as of... comment number

Prashant.c’s picture

Followed the steps by #9 and able to reproduce this error.
Also getting warnings after enabling the module ui_cache_clear attaching screenshots.

Prashant.c’s picture

Status: Needs review » Needs work
oheller’s picture

FileSize
132.34 KB
110.72 KB

While trying to recreate #9 I had the below issues. Here is the process I made it through.

1) Install Drupal: English, Standard profile, MySQL database
2) Enable Language + Interface translation module
3) Enable a language: Dutch
4) Download a module: UI Cache Clear
5) Add a line to the ui_cache_clear.info.yml file: project: "ui_cache_clear" (the packaging script does not yet work with D8 .info.yml files)
6) Enable the module: admin/modules - Error Language2

7) Install and enable Rules module.
8) Uninstall Rules module (wanted to add project:"rules" to rules.info.yml) - Error Language4

I haven't been able to reproduce this yet.

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.

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.

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.

g-brodiei’s picture

Status: Needs work » Closed (cannot reproduce)
Issue tags: -Needs manual testing +Bug Smash Initiative

As part of Bush Smash Initiative,

I'm trying to reproduce the bug following instructions on the issue summary updated by @YesCT and #9. I'd also tried the steps on #27 by @oheller. Big thanks to all previous contributors providing tests and patches.

Do note that adding new line to {module_name}.info.yml file as mentioned on Step 5 of IS is not tested since the packing script of drupal.org adds this automatically already.

I did the following steps,

1. Fresh install 8.9.x, php 7.3, mysql 5.7
2. Enable interface translation module (locale)
3. Add new language Chinese, Traditional at admin/config/regional/language
3. Install taxonomy menu module with composer require drupal/taxonomy_menu
4. Check admin/reports/translations, no errors were shown
5. Uninstall taxonomy menu module
6. Check admin/reports/translations, no errors were shown again
7. Tried with new language Afrikaans, and repeat step 4-6.

Still no error or bug shown like issue description.

Therefore, I'm closing this issue as it cannot be reproduced.