Installed http://drupal.org/project/multilingual_demo. Having removed Spanish and Hungarian languages get WSD when trying to list content with Recent Log Entires giving message:

Notice: Undefined index: hu in Drupal\Core\Entity\ContentEntityBase->language() (line 520 of .../core/lib/Drupal/Core/Entity/ContentEntityBase.php).

Comments

gábor hojtsy’s picture

Title: WSD and Undefinded index » WSOD with listing content after removing language
Priority: Normal » Major
Issue summary: View changes

Right, I don't think Drupal core ever solved the problem of deleting a language which has content/configuration in it. Content that was translated to that language as well as configuration in that language will start behaving unpredictably when removing languages. We should be moving this to the core queue and elevating to critical if we can reproduce with core only. I tried the following step but failed:

1. Install in English.
2. Add Afrikaans.
3. Enable articles for content translation.
4. Add an article, translate it to Afrikaans too.
5. Remove Afrikaans.
6. Visit admin/content. No WSOD. :/

Can you reproduce with core too?

kristen pol’s picture

I just tried with latest demo version (8.0.0 core) and do get a fatal error:

  1. Install demo
  2. Enable Afrikaans
  3. Enable content translation on product
  4. Translate a product to Afrikanns
  5. Disable Afrikaans
  6. Go to /admin/content
  7. Fatal error:

    Fatal error: Call to a member function getId() on a non-object in /home/dmmcm/www/core/modules/system/src/Plugin/views/field/BulkForm.php on line 454
gábor hojtsy’s picture

I think this is a core bug. I did try to reproduce it with core only though unsuccessfully :/ We don't change anything about the node admin page, so not sure why would it only come up with the demo...

kristen pol’s picture

Status: Active » Postponed (maintainer needs more info)

Postponing for now so we can do some more testing to see if it's a core issue.

loopduplicate’s picture

Project: Drupal 8 multilingual demo » Drupal core
Version: 8.x-1.x-dev » 8.0.x-dev
Component: Code » language system
Status: Postponed (maintainer needs more info) » Active

I can reproduce this with just Drupal core.

* Install latest Drupal 8 with English as the default language
* Enable language and content translation modules
* Add Afrikaans and Albanian to languages (make sure to install both languages)
* Enable translation on the Article content type
* Add a node in English
* Translate the node in Afrikaans and Albanian
* Remove Afrikaans from languages
* Visit admin/content
* Server error
PHP Fatal error: Call to a member function getId() on null in /Applications/MAMP/htdocs/d8sandbox/docroot/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php on line 259

SakaSerbia’s picture

StatusFileSize
new34.64 KB
new34.17 KB
new35.67 KB

* Install latest Drupal 8 with English as the default language
* Enable language and content translation modules
* Add Serbian and Albanian to languages (make sure to install both languages)
* Enable translation on the Article content type
* Add a node in Serbian
* Translate the node in Serbian and Albanian
* Remove Albanian from languages
* Visit admin/content
* Server error

Fatal error: Call to a member function getId() on null in /beta2/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php on line 259

For me error is no page and /rs. Front page in EN work perfect.

SakaSerbia’s picture

Version: 8.0.x-dev » 8.0.1

I uninstall and after install the theme in admin/appearance and bag is fixed..

loopduplicate’s picture

Hi s-a-k-a,

I'm having trouble understanding your last comment. Can you clarify it a bit?

Thanks,
loopduplicate

catch’s picture

Version: 8.0.1 » 8.0.x-dev

We should probably prevent deletion of the language if there's any content in the language.

I can see that being annoying if there's only translations and you really want to remove support for a language, but we don't support bulk deletes properly yet.

gábor hojtsy’s picture

Right, that sounds like an API addition to ask everyone that may want to stop deleting a language. There may be path aliases in that language, config translations, locale translations, etc. So far only content has issues with WSOD-ing when the language is not there, but the question is whether we should be consistent with the rest of them as well.

catch’s picture

We should probably prevent deletion of the language if there's any content in the language.

I can see that being annoying if there's only translations and you really want to remove support for a language, but we don't support bulk deletes properly yet so removal isn't doable at the moment.

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.

rcodina’s picture

Any update on this? I think there should be a warning message before deletion that recommends you about deleting any content in the language you want to remove.

gábor hojtsy’s picture

@rcodina: right, we need a system first to identify all "content" (taxonomy terms, users, products, rules, views, etc.) in the language you are deleting. Introducing such a system would be the next step.

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.

cgmonroe’s picture

We had to remove a language that was partially implemented when the Powers That Be decided not to translate the bulk of the content.

In order to remove the language, I needed to identify all the translated content. I did this with the quick script below. It just handles the entities and not views or other items. But it was good enough for what we needed.

Posting it just to help others in this situation and possibly usable in the final solution.

Best run via the "drush scr" command. It will print out the entity type and id of entities that have translations in the specified language .

This info can be used to go into the GUI and remove the translations. E.g. if it's a node type, /node/###/translations to get to the list of translations, then you can delete the language you don't want from there. Menus, blocks, and the like all have similar URLs that you can plug the id into. Still a pain but faster than trying to find these manually.

Once you've deleted the unwanted translations for these entities, you probably can safely remove the language. The main reasons for the WSOD is the entity admin screens. YMMV

NOTES:

If you are using paragraph entities (paragraphs module), deleting the node translation should delete these for you.

You may need to manually check for translated menu's (not menu link items) as these are config items and not entities.

Here's the script

// Language code for the language you are looking for translations of.
$lang = 'nl';

$transTypes = array();
$definitions = \Drupal::entityTypeManager()->getDefinitions();
foreach ( $definitions as $id => $definition ) {
  if ( $definition->isTranslatable() ) {
    $transTypes[] = $id;
  }
}

foreach ($transTypes as $type ) {
  $entities = get_entities($type);
  print "Processing " . count($entities) ." entities of type $type\n";

  foreach ($entities as $id) {
    $entity = \Drupal::entityTypeManager()->getStorage($type)->load($id);
    if ($entity->hasTranslation($lang) ) {
       print "  Found $lang translation in type $type, id $id\n";
    }
  }
}

function get_entities( $entity_type ) {
  $query = \Drupal::entityQuery($entity_type);
  $results = $query->execute();
  return $results;
}
roderik’s picture

Status: Active » Closed (duplicate)
Related issues: +#2851029: [PP-1] Disallow removing a language when there is content in that language

Closing in favor of #2851029 since that was updated last.