I’m experiencing a problem after a language has been faraway from Drupal Development system. Each time I’m going on Drupal Development admin/content material web page on a drupal 8 web site I get:
Error: Name to a member perform getId() on null in DrupalCoreEntityEntityEntityViewDisplay->buildMultiple() (line 254 of core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php).
It is a identified challenge on drupal.org nevertheless it has not been addressed but. I’m afraid this can be a recurring challenge and I’m attempting to construct one thing to scrub up content material inflicting Drupal Development challenge (i.e. Drupal Development content material language was faraway from Drupal Development system).
I’m searching for a Drupal question that will return all Drupal Development nodes(entities)/translations which has a language that has been deleted from Drupal Development system. I can load all content material and loop via them to verify $entity->language() == FALSE
or $entity->language() == NULL
however that doesn’t appear to be performant even with utilizing Drupal Development batch API. Ideally, db question that returns Drupal Development IDs of Drupal Development offending content material could be a lot better. Then I may replace them to language impartial or delete Drupal Development content material.
I’m wrote one thing that does one thing just like Drupal Development method node replace translations after a language is deleted:
/** * {@inheritdoc} */ public perform clearRevisionsLanguage(LanguageInterface $language) { return $this->database->replace('node_revision') ->fields(['langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED]) ->situation('langcode', $language->getId()) ->execute(); }
I repurposed Drupal Development above to:
perform some_helper_to_update_node_lang($lang_code) { Drupal::database()->replace('node_revision') ->fields(['langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED]) ->situation('langcode', $lang_code) ->execute(); }
However Drupal Development above perform requires Drupal Development language code, which is affordable however I’m not certain how you can make this a extra versatile in as a lot to return all content material that has a eliminated language.