- Status changed to Needs review
almost 2 years ago 2:55am 2 February 2023 The last submitted patch, 12: drupal-10.1.x-core-drupal_static-3136041-12-TEST-ONLY-FAIL.patch, failed testing. View results →
- Status changed to Needs work
almost 2 years ago 5:12pm 2 February 2023 - 🇺🇸United States smustgrave
Wow thanks for the quick turnaround!
Only nit picky thing I see (and found thanks to phpstorm)
return $data[$name];
Can we move this out of the if/else and just have it outside both. Since both cases return the same thing, would be one less line of code.Other then that everything looks good!
Great job with the test!
- Status changed to Needs review
almost 2 years ago 11:48pm 2 February 2023 - 🇳🇿New Zealand jweowu
True. I suspect I did that on purpose so that the code for each of those scenarios was very self-contained, but I really can't decide now which way around I prefer it, so here's a revised patch with that change. I think both ways are fine.
- Status changed to RTBC
almost 2 years ago 11:58pm 2 February 2023 - 🇺🇸United States smustgrave
It was nit picky thing fully admit. But figured I'd ask now so no one else did down the line. The rest looks good to me.
The last submitted patch, 15: drupal-10.1.x-core-drupal_static-3136041-15.patch, failed testing. View results →
The last submitted patch, 15: drupal-10.1.x-core-drupal_static-3136041-15.patch, failed testing. View results →
The last submitted patch, 15: drupal-10.1.x-core-drupal_static-3136041-15.patch, failed testing. View results →
- Status changed to Needs review
almost 2 years ago 1:07pm 8 March 2023 - Status changed to Needs work
almost 2 years ago 7:07am 9 March 2023 - 🇳🇿New Zealand jweowu
Needs re-roll per https://www.drupal.org/project/drupal/issues/3346645#comment-14959118 📌 Eliminate anti-pattern isset($arr[$key]) || array_key_exists($key, $arr) Fixed
- 🇳🇿New Zealand jweowu
Well... in fact bootstrap.inc isn't a namespaced file, so that was actually still fine -- but perhaps it's sensible to use
\array_key_exists()
as standard regardless, just as best-practice. - Status changed to Needs review
almost 2 years ago 11:22am 9 March 2023 - Status changed to RTBC
almost 2 years ago 4:15pm 9 March 2023 - 🇺🇸United States smustgrave
Since only change was \array_key_exists() and no failures think this is good.
The last submitted patch, 34: drupal-10.1.x-core-drupal_static-3136041-34.patch, failed testing. View results →
The last submitted patch, 34: drupal-10.1.x-core-drupal_static-3136041-34.patch, failed testing. View results →
- 🇮🇹Italy apaderno Brescia, 🇮🇹
+ // Reset all: ($name == NULL). This needs to be done one at a time so that + // references returned by earlier invocations of drupal_static() also get + // reset.
Should not one at a time be once at a time?
- 🇳🇿New Zealand jweowu
I wouldn't think so. "One at a time" seems appropriate here, as we're doing something to each array item individually.
- Status changed to Fixed
over 1 year ago 8:03am 4 April 2023 - 🇬🇧United Kingdom catch
array_key_exists() isn't the only change here, it's moving the bulk of the logic of the function after an isset($name). The array_key_exists() change is unnecessary, but it's consistent with 📌 Eliminate anti-pattern isset($arr[$key]) || array_key_exists($key, $arr) Fixed now that PHP has optimized array_key_exists(), and hopefully we won't touch this logic again until deprecating per 🌱 [META] Remove all usages of drupal_static() & drupal_static_reset() Active (and hopefully sooner than another ten years).
diff --git a/core/tests/Drupal/KernelTests/Core/Bootstrap/ResettableStaticTest.php b/core/tests/Drupal/KernelTests/Core/Bootstrap/ResettableStaticTest.php index 4e55b1d96f..7ad4b0d126 100644 --- a/core/tests/Drupal/KernelTests/Core/Bootstrap/ResettableStaticTest.php +++ b/core/tests/Drupal/KernelTests/Core/Bootstrap/ResettableStaticTest.php @@ -37,7 +37,7 @@ public function testDrupalStatic() { drupal_static_reset(); $this->assertEquals('foo', $var, 'Variable was reset after second invocation of global reset.'); - // Test the empty string naming edge case for issue #3136041. + // Test calling drupal_static() with no arguments (empty string). $name1 = __CLASS__ . '_' . __METHOD__ . '1'; $name2 = ''; $var1 = &drupal_static($name1, 'initial1');
Made this change on commit since we usually rely on git blame for links back to issues. Committed/pushed to 10.1.x, thanks!
- 🇳🇿New Zealand jweowu
Thanks all. (And thanks smustgrave for keeping on top of the false-positive status updates.)
Automatically closed - issue fixed for 2 weeks with no activity.