- Issue created by @NicholasS
- Merge request !120Optimize environment indicator processing by checking user permissions and environment name early β (Closed) created by NicholasS
- πΊπΈUnited States NicholasS
I think these changes should have perf improvement since it bails early for anon users and don't waste time with config calls. But I won't really know until it released to prod, but I don't see it breaking anything locally.
- πΊπΈUnited States trackleft2 Tucson, AZ πΊπΈ
Hi @nicholass, thank you for your interest in contributing to this module.
I appreciate the performance improvement effort here, especially the early permission check to bail out for anonymous users.
However, I donβt think we should bypass the environment_indicator.indicator service in favor of direct calls to
\Drupal::config('environment_indicator.indicator'
). In the current implementation that may appear safe, but we are actively moving toward allowing plugins to determine the active environment dynamically. See π Implement the current environment as a service and utilize plugins Active as an example.The service abstracts that logic and will be responsible for resolving the correct environment indicator configuration, potentially via plugins, request context, or other mechanisms. Reaching directly into the config system here introduces future technical debt and increases the risk of bugs once plugin support is added.
I recommend:
- Keeping the early return for permissions, as that is a clear performance improvement.
- Continuing to call
$environment_indicator->getActiveEnvironment()
(or an equivalent method), rather than using\Drupal::config(...)
directly, even if the result is cached earlier in the function.
- Merge request !121Optimize permission checks in environment_indicator module to reduce... β (Closed) created by NicholasS
- Merge request !122Issue #3535214 return early for users without permission to view environment indicator. β (Open) created by trackleft2
- πΊπΈUnited States NicholasS
Awe ok I see you working on a version of this for 4.0.24, that explains why I could use composer to test the patch on our site, so I will pause my MR121 in favor of your branch. I did switch to the dev branch and was able to test MR121 and it seemed fine to me.
Glad your looking into it thank you.
- πΊπΈUnited States trackleft2 Tucson, AZ πΊπΈ
Here's a patch for 2.0.24
Feel free to update my merge request with improvements.
- πΊπΈUnited States trackleft2 Tucson, AZ πΊπΈ
Oops, it looks like I missed adding this improvement to the global functions like hook_page_top and hook_toolbar that live in the base module (
environment_indicator
.) - πΊπΈUnited States NicholasS
MR121 looks good to me, no errors our Cypress e2e testing suite dropped from 34:41 to 34:02 so I think this hopefully have a performance impact, but I will only truly know really until its on a prod environment with much more sustained traffic to really know.
Thank you @trackleft2