Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Part of meta-issue #2002650: [meta, no patch] improve maintainability by removing unused local variables
File /core/modules/block/block.module
Line 513: Unused local variable $block_counter
Line 568: Unused local variable $block_id
Line 582: Unused local variable $block_id
Line 608: Unused local variable $block_id
Comment | File | Size | Author |
---|---|---|---|
#4 | core-remove-unused-local-variables-block.module-2057149-4.patch | 1.45 KB | legolasbo |
Comments
Comment #1
legolasboI've located all four of these variables and have come to the following conclusion.
$block_counter is used as part of the drupal cache process if i've understood the meaning of &drupal_static(__FUNCTION__, array()); correctly.
All instances of $block_id are actually unused, but are (the key) part of a foreach loop. I think removing these won't do the performance of their functions any good, but will reduce code understandability.
In my opinion we should leave these variables untouched.
Comment #2
legolasboComment #3
legolasboBecause of a discussion in #2057157: Remove Unused local variable $plugin from /core/modules/views/views.module the unused foreach key variables will be removed. I'll supply a patch soon.
Comment #4
legolasboAttached patch removes the unused foreach key variables.
Comment #5
benjy CreditAttribution: benjy commentedAll good.
Comment #6
webchickCommitted and pushed to 8.x. Thanks!