Possible dead code Plugin/views/PluginBase.php

Created on 21 June 2024, 3 months ago
Updated 16 July 2024, about 2 months ago

Problem/Motivation

alexpott spotted this while reviewing this section from core/modules/views/src/Plugin/views/PluginBase.phpas part of #3123067: Fix 'Drupal.Semantics.FunctionT.NotLiteralString' coding standard β†’ .

    if ($flags & LanguageInterface::STATE_SITE_DEFAULT) {
      $name = $languages[LanguageInterface::LANGCODE_SITE_DEFAULT]->getName();
      // The language name may have already been translated, no need to
      // translate it again.
      // @see Drupal\Core\Language::filterLanguages().
      if (!$name instanceof TranslatableMarkup) {
        // phpcs:ignore Drupal.Semantics.FunctionT.NotLiteralString
        $name = $this->t($name);
      }

The comment copied here for convenience,

This is highly suspect code. I think it is not necessary. Given the code in \Drupal\Core\Language\LanguageManager::filterLanguages() which this points to incorrectly. I think we should file a follow-up to look at this code. I think it is dead code.
I also think there is a bug in \Drupal\Core\Language\LanguageManager::filterLanguages() because I managed to make it return

> $l['site_default']->getName();
= Drupal\Core\StringTranslation\TranslatableMarkup {#6621
    markup: "Standardsprache der Website (German)",
  }

And it should not ever mix languages like that but this is not in scope here.

Steps to reproduce

Proposed resolution

TBA

Remaining tasks

Investigate the code and decide on what to do

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 11 hours ago

Created by

πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024