Problem/Motivation

build_hooks_entity_* call to the service container twice for the same service, each of them calls build_hooks_get_trigger_service twice

Steps to reproduce

Proposed resolution

Call it once and store it in a local variable or make deployFrontendEntityUpdateEnvironments return $this and chain the calls

Remaining tasks

User interface changes

API changes

Data model changes

Comments

larowlan created an issue. See original summary.

larowlan’s picture

Issue tags: +Novice
Pooja Ganjage’s picture

StatusFileSize
new2.47 KB

Hi,

I am creating a patch for this issue.

Kindly review the patch once.

Thanks.

Pooja Ganjage’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 3: 3172103-3.patch, failed testing. View results

larowlan’s picture

+++ b/build_hooks.module
@@ -39,10 +39,11 @@ function build_hooks_cron() {
-      build_hooks_get_trigger_service()->deployFrontendEntityUpdateEnvironments();
...
+      $loggerService->deployFrontendEntityUpdateEnvironments();
+      $loggerService->invalidateToolbarCacheTag();

@@ -52,10 +53,11 @@ function build_hooks_entity_update(EntityInterface $entity) {
-      build_hooks_get_trigger_service()->deployFrontendEntityUpdateEnvironments();
-      build_hooks_get_trigger_service()->invalidateToolbarCacheTag();

@@ -65,10 +67,11 @@ function build_hooks_entity_insert(EntityInterface $entity) {
-      build_hooks_get_trigger_service()->deployFrontendEntityUpdateEnvironments();
-      build_hooks_get_trigger_service()->invalidateToolbarCacheTag();

the logger service isn't the one we need a variable for (its only called once) - instead its the trigger service we need a variable for.

anushrikumari’s picture

Status: Needs work » Needs review
StatusFileSize
new3.38 KB

Created the patch as per comment #6 @larowlan please review.

larowlan’s picture

Status: Needs review » Needs work

Thanks for this

+++ b/build_hooks.module
@@ -158,8 +162,9 @@ function build_hooks_toolbar_alter(&$items) {
+  $triggerService = build_hooks_get_trigger_service();
...
-    'tags' => ['config:frontend_environment_list', build_hooks_get_trigger_service()->getToolbarCacheTag()],

let's reverse this one, we're only using it once in this function so there's no need to create a variable - unlike the other functions, where we use it twice

anushrikumari’s picture

Status: Needs work » Needs review
StatusFileSize
new2.88 KB

I've made the suggested changes, please review.

larowlan’s picture

Status: Needs review » Fixed

Thanks! 💪

larowlan’s picture

Status: Fixed » Closed (fixed)

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