Problem/Motivation

Remove unused variable $translation from BulkFormTest. There are couple of instances

core/modules/node/tests/src/Functional/Views/BulkFormTest.php

// Create translations for all languages for some nodes.
    for ($i = 0; $i < 2; $i++) {
      $node = $this->nodes[$i];
      foreach ($langcodes as $langcode) {
        if (!$node->hasTranslation($langcode)) {
          $title = $this->randomMachineName() . ' [' . $node->id() . ':' . $langcode . ']';
          $translation = $node->addTranslation($langcode, ['title' => $title, 'promote' => FALSE]);
        }
      }
      $node->save();
    }
    // Create a node with only one translation.
    $node = $this->nodes[2];
    $langcode = 'en';
    $title = $this->randomMachineName() . ' [' . $node->id() . ':' . $langcode . ']';
    $translation = $node->addTranslation($langcode, ['title' => $title]);
    $node->save();

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 3331900-2.patch1.27 KBnoorulshameera

Comments

anmolgoyal74 created an issue. See original summary.

noorulshameera’s picture

Status: Active » Needs review
StatusFileSize
new1.27 KB

Adding a patch which removes the unused variables.

anmolgoyal74’s picture

Title: Remove unused variable $translation from MoveTest » Remove unused variable $translation from BulkFormTest
nidhi27’s picture

Status: Needs review » Reviewed & tested by the community

This patch is working as expected and removing the unused variables.

alexpott’s picture

Version: 10.1.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

We do have automated code checks for unused variables but assignment in a loop is tricky to check for so they must not catch this one.

Committed and pushed 121e42f8b4 to 10.1.x and f24cbd8b99 to 10.0.x and 2760d9bac1 to 9.5.x. Thanks!

Backported to 9.5.x to keep tests aligned.

  • alexpott committed 121e42f8 on 10.1.x
    Issue #3331900 by noorulshameera, anmolgoyal74: Remove unused variable $...

  • alexpott committed f24cbd8b on 10.0.x
    Issue #3331900 by noorulshameera, anmolgoyal74: Remove unused variable $...

  • alexpott committed 2760d9ba on 9.5.x
    Issue #3331900 by noorulshameera, anmolgoyal74: Remove unused variable $...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.