Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
I assume this patch was created using some sort of linter. Linters cannot do a complete analysis of PHP. For example, you can refer to a variable with another variable, in the form $$my_variable_reference. Each of these changes needs to be individually looked at and tested.
I someone does that, I'd be happy to commit this. It's a LOT of work.
I get that. But I never commit anything by just reading the code. I actually test it either with an automated test (seldom) or manually usually). It would be silly to introduce a regressing just to pretty up the code.
Also, some of the foreach index variables make the code self-documenting. cid for example.
@joelpittet -- When you say "this looks good", are you saying that you're reviewed it sufficiently to commit? I hesitate to commit a big patch like this without someone (not me) personally testing every change. Also, I'm plus/minus on removing the unused foreach keys. They provide valuable documentation to future maintainers. We could just remove them, we could add a comment, or we could leave them. I'm not sure what's best.
re #13 @DanChadwick I usually mark it RTBC if review it entirely. I was wondering how to best break this change up to make it easier to review the way you'd like it.
array_pop will modify the $parents array. While the $action variable may not be needed the array_pop is needed for sure.
Read through all of them, there are two that are wrong, all the others are correct. I'll leave the decision about the foreach unused key variables up to @DanChadwick but I lean towards leaving them alone.
Comments
Comment #2
heykarthikwithuremoved the unused variables in the code, added a patch for this.
Comment #3
heykarthikwithuComment #4
heykarthikwithuComment #5
danchadwick commentedHave you tested each of these?
I assume this patch was created using some sort of linter. Linters cannot do a complete analysis of PHP. For example, you can refer to a variable with another variable, in the form $$my_variable_reference. Each of these changes needs to be individually looked at and tested.
I someone does that, I'd be happy to commit this. It's a LOT of work.
Comment #6
heykarthikwithuyes this was tested, and this was a manual review of code, any how using a IDE for to do this.
Comment #7
danchadwick commentedCan you elaborate on how you tested this?
Comment #8
heykarthikwithu$uservariable is not used anymore inside the function.$rowand$first_rowvariables are not used anymore inside the function.$componentis not used anymore inside the fucntion.$question_keyis not used inside the foreach loop.$keyis not used inside the foreach loop.$form_keyvarible is not used in the function.$nodevariable is not used inside the function.$form_keyvariable is not more used inside the function.$cidis not used inside the foreach loop.$queryvariable is not used anymore in further code, so this can be removed.$delete_conditionalvariable is not used inside the function.$cidand$keyvariables are no more used inside the foreach.$actionvariable is not used in further code.$eidvariable is no more used inside the fucction.$componentsand$headervariable are no more used inside the fucntion.$sidvariable is not used in the foreach.$sidsvariable is no more used inside the function.$eidand$aidvariables are not used inside the foreach.$conditional_resultand$matchesvariables are no more used inside the function.$sub_cid,$sid,$key,$cid,$eid,$cidvariables are no more used inside their foreach loops.$uservarible is no more used inside the function.$type,$cidvariables are no more used inside the foreach.Comment #9
danchadwick commentedI get that. But I never commit anything by just reading the code. I actually test it either with an automated test (seldom) or manually usually). It would be silly to introduce a regressing just to pretty up the code.
Also, some of the foreach index variables make the code self-documenting. cid for example.
Comment #10
heykarthikwithuChecked manually by debugging the code where all i found the unused variables, and confirmed the few variables are no more used inside the function.
Comment #11
joelpittetThis looks good. @DanChadwick maybe it would be easier if it was one type of variable clean up at a time?
Comment #12
heykarthikwithuComment #13
danchadwick commented@joelpittet -- When you say "this looks good", are you saying that you're reviewed it sufficiently to commit? I hesitate to commit a big patch like this without someone (not me) personally testing every change. Also, I'm plus/minus on removing the unused foreach keys. They provide valuable documentation to future maintainers. We could just remove them, we could add a comment, or we could leave them. I'm not sure what's best.
Comment #14
joelpittetre #13 @DanChadwick I usually mark it RTBC if review it entirely. I was wondering how to best break this change up to make it easier to review the way you'd like it.
Comment #15
joelpittetThis variable needs to stay as it initializes each loop.
array_pop will modify the $parents array. While the $action variable may not be needed the array_pop is needed for sure.
Read through all of them, there are two that are wrong, all the others are correct. I'll leave the decision about the foreach unused key variables up to @DanChadwick but I lean towards leaving them alone.
Comment #16
liam morlandPatch no longer applies. Please re-roll and take into account the issues mentioned in #15. Let's leave alone the unused foreach variables.
Comment #17
liam morlandIt would be easier to review if different kinds of changes were made in separate patches.
Comment #18
liam morlandAre you still interested in working on this?
Comment #19
joelpittet@Liam Morland I am, don't mind rerolling this.
Comment #20
joelpittetComment #21
liam morlandComment #22
joelpittetAddressed my notes from #15, and removed all foreach as indicated in #16 and rerolled.
Comment #23
joelpittetComment #25
liam morlandThanks very much!