question to retrieve all translations and nodes of a language that has been faraway from Drupal Development system?

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.

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

question to retrieve all translations and nodes of a language that has been faraway from Drupal Development system?

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.