Unused local variable $key (at line 49) in file.field.inc

Created on 27 October 2015, over 8 years ago
Updated 28 March 2023, about 1 year ago

Unused local variable $key (at line 49), 'file' module, 'file.field.inc' file.

🐛 Bug report
Status

Fixed

Version

10.1

Component
File module 

Last updated 3 days ago

Created by

🇮🇳India heykarthikwithu Bengaluru 🌍

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States smustgrave

    Running for 10.1 but don't expect a failure.

  • Status changed to Needs work over 1 year ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    If we're going to remove this I think we should take the opportunity to make the code inside more consistent. In the loop we have

        foreach (Element::children($widget) as $sub_key) {
          if (isset($widget[$sub_key]['#type']) && $widget[$sub_key]['#type'] == 'submit') {
            hide($widget[$sub_key]);
            $operations_elements[] = &$widget[$sub_key];
          }
        }
    

    and

        foreach (Element::children($operations_elements) as $key) {
          show($operations_elements[$key]);
        }
    

    I think now we're removing the $key from the containing loop we should be changing the first internal Element::children() to use $key instead of $sub_key because now sub_ is pretty meaningless.

  • 🇳🇿New Zealand quietone New Zealand

    Change parent to the issue implementing the sniff.

  • Status changed to Needs review over 1 year ago
  • Addressed the points mentioned in #38

  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States smustgrave

    foreach (Element::children($operations_elements) as $sub_key) {

    Will let the committer decide this one but not sure if this should be sub_key but since we used $key in the loop above it maybe it's fine.

  • Status changed to Needs work over 1 year ago
  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    No, making this sub key is super confusing, back to needs work imho.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India Rashmisoni Bangalore

    Addressed the points mentioned in #38 in Patch #40, Currently, Parent loops is not using $key So used $key instead of $sub_key and that loop ended in line no 65. IMO line number 91 changes not required as it starts with different loop. Please review.

  • 🇮🇳India Rashmisoni Bangalore

    Sorry wrong interdiff.

  • 🇮🇳India Aziza Anwari Gujarat

    Checked the patch given on #43 , it apply's cleanly and have also addressed the previous comments

    +RTBC

  • Status changed to RTBC about 1 year ago
  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    @aziza_a, adding a screenshot that code applies is not helpful, the bots tell us that. Please don't do that.

    The patch in #43 has made the changes I requested in #42, looks good to me now.

    • catch committed 80b3daf9 on 10.1.x
      Issue #2602326 by Rassoni, Rishabh Vishwakarma, heykarthikwithu, paulocs...
  • Status changed to Fixed about 1 year ago
  • 🇬🇧United Kingdom catch

    In general I don't think we should treat array keys in foreach loops as unused but in this case it's improving readability overall so seems like a good change. Committed/pushed to 10.1.x, thanks!

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

Production build 0.69.0 2024