Problem/Motivation

In core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php file in function testGetTasksBuildWithCacheabilityMetadata() $local_tasks is initialized but never used.

Proposed resolution

Remove unused $local_tasks variable.

public function testGetTasksBuildWithCacheabilityMetadata() {
...... 

       ->willReturn(new ParameterBag());
 
     $cacheability = new CacheableMetadata();
-    $local_tasks = $this->manager->getTasksBuild('menu_local_task_test_tasks_view', $cacheability);
-
     // Ensure that all cacheability metadata is merged together.
     $this->assertEquals(['tag.example1', 'tag.example2'], $cacheability->getCacheTags());
     $this->assertEquals(['context.example1', 'context.example2', 'route', 'user.permissions'], $cacheability->getCacheContexts());

Comments

Hardik_Patel_12 created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, unsused-variable-removed.patch, failed testing. View results

mayurjadhav’s picture

StatusFileSize
new816 bytes
new847 bytes
$this->manager->getTasksBuild('menu_local_task_test_tasks_view', $cacheability);

is necessary to run the test.

Added updated patch with interdiff, Kindly review.

mayurjadhav’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 3: unsused_variable-3158278-3.patch, failed testing. View results

mayurjadhav’s picture

Status: Needs work » Needs review

#3 is a random failure, Moving back to NR, as retest is passed.

paulocs’s picture

Status: Needs review » Reviewed & tested by the community

Patch #3 looks good to me.

The variable $local_tasks was added in issue #2511516: Make local tasks and actions hooks provide cacheability metadata, to make the blocks showing them cacheable.
There is no need have this variable. Set to RTBC.

Cheers, Paulo.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 3: unsused_variable-3158278-3.patch, failed testing. View results

hardik_patel_12’s picture

Status: Needs work » Reviewed & tested by the community

Random failure , setting back to RTBC.

  • catch committed d0c9515 on 9.1.x
    Issue #3158278 by mayurjadhav, Hardik_Patel_12, paulocs: Unused local...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed d0c9515 and pushed to 9.1.x. Thanks!

Status: Fixed » Closed (fixed)

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