# Hook greift nicht, erst nach "neuinstallation"

**URL:** https://forum.shopware.com/t/hook-greift-nicht-erst-nach-neuinstallation/67501
**Category:** Programmierung
**Created:** [8. Juni 2020 um 12:24 UTC](https://forum.shopware.com/t/hook-greift-nicht-erst-nach-neuinstallation/67501 "2020-06-08T12:24:58Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![exwe](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@exwe](https://forum.shopware.com/u/exwe)
#### Post date: [8. Juni 2020 um 12:24 UTC](https://forum.shopware.com/t/hook-greift-nicht-erst-nach-neuinstallation/67501/1 "2020-06-08T12:24:58Z")

</div>

Hallo Leute,

ich baue gerade ein Plugin mit Hooks.

Ich leere nach der Aktivierung alle Caches mit CACHE\_LIST\_ALL.  
Trotzdem greift mein Hook nicht. Erst wenn ich im Plugin einmal „neuinstallieren“ wähle, greift er.

```
public function activate(ActivateContext $context){
      $context->scheduleClearCache(ActivateContext::CACHE_LIST_DEFAULT);
      return true; 
    }

    public function install(InstallContext $context)
	  {   
      $context->scheduleClearCache(InstallContext::CACHE_LIST_DEFAULT);
      return true; 
    }
  
    public function uninstall(UninstallContext $context){
      $context->scheduleClearCache(UninstallContext::CACHE_LIST_DEFAULT);
      return true; 
    }

    public function update(UpdateContext $context){
      $context->scheduleClearCache(UpdateContext::CACHE_LIST_DEFAULT);
      return true; 
    }

```

Kann sich das jemand erkläen?

&nbsp;

Gruß Yuri

---

<div class="post-metadata">

### Author: ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)
#### Post date: [9. Juni 2020 um 14:43 UTC](https://forum.shopware.com/t/hook-greift-nicht-erst-nach-neuinstallation/67501/2 "2020-06-09T14:43:12Z")

</div>

Hallo Yuri,

im Text schreibst du zwar, du nutzt CACHE\_LIST\_ALL, aber in deinem Beispiel Code nicht. Was denn nun?&nbsp; ![Smile](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/smile.png "Smile")&nbsp;Normalerweise sollte es ausreichen den Cache komplett zu leeren.

Viele Grüße aus Schöppingen

![cool](http://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/shopware.png "cool")&nbsp;Michael Telgmann

---

<div class="post-metadata">

### Author: ![exwe](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@exwe](https://forum.shopware.com/u/exwe)
#### Post date: [9. Juni 2020 um 15:24 UTC](https://forum.shopware.com/t/hook-greift-nicht-erst-nach-neuinstallation/67501/3 "2020-06-09T15:24:38Z")

</div>

Hallo Michael,

da hast du recht, ich hatte allerdings beides getestet und beides hatte nicht den gewünschten Effekt.

Ich habe es nun durch viel probieren hinbekommen, indem man so vorgeht:

```
public function activate(ActivateContext $context){

      // force clear Shopware Proxies
      $cacheManager = Shopware()->Container()->get('shopware.cache_manager');
      $cacheManager->clearProxyCache();

      $context->scheduleClearCache(ActivateContext::CACHE_LIST_DEFAULT);

      return true; 
    }

```

&nbsp;

Erst wenn man den Cache doppelt leert, generiert sich die Datei sauber neu mit neuem array in der getHookMethods(). Die neuinstallation triggert irgendwie wohl dieses doppelte Cache leeren. Mein Versuch den Cache zu leeren einmal im install und einmal im activate funktioniert hingehen nicht.

Für mich riecht das nach einem Bug, aber ich kann es nicht belegen.

Gruß und danke schon mal!

&nbsp;

&nbsp;

---

<div class="post-metadata">

### Author: ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)
#### Post date: [10. Juni 2020 um 05:56 UTC](https://forum.shopware.com/t/hook-greift-nicht-erst-nach-neuinstallation/67501/4 "2020-06-10T05:56:30Z")

</div>

Hallo Yuri,

der Cache Tag&nbsp;CACHE\_TAG\_PROXY ist eigentlich Teil der&nbsp;CACHE\_LIST\_DEFAULT. Daher sollte ein eigener Aufruf des CacheManagers nicht nötig sein. Falls das so nicht von alleine funktioniert, erstelle mal bitte dazu ein Ticket. Am besten mit Beispiel Plugin, damit wir das möglichst einfach nachvollziehen können.

Viele Grüße aus Schöppingen

![cool](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/86c57fbace799dd4eb1f1b8a2d3bdc1733f0aea1.png "cool")&nbsp;Michael Telgmann

---

<div class="post-metadata">

### Author: ![exwe](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@exwe](https://forum.shopware.com/u/exwe)
#### Post date: [10. Juni 2020 um 07:40 UTC](https://forum.shopware.com/t/hook-greift-nicht-erst-nach-neuinstallation/67501/5 "2020-06-10T07:40:28Z")

</div>

[@Michael Telgmann]([http://forum.shopware.com/profile/17553/Michael](http://forum.shopware.com/profile/17553/Michael) Telgmann “Michael Telgmann”)‍ habe ich dir angelegt. Man kann leider keine zip hochladen. Hab euch daher das Testplugin ein ein Drive geladen. Wenn das nicht geht schreib mir bitte mal kurz privat. Wäre cool, wenn du dazu mal kurz Feedback hast, ob es ein Bug ist oder wir zu blöd 😃

> **[Shopware Issuetracker](https://issues.shopware.com/issues/SW-25481)**

---

<div class="post-metadata">

### Author: ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)
#### Post date: [10. Juni 2020 um 08:16 UTC](https://forum.shopware.com/t/hook-greift-nicht-erst-nach-neuinstallation/67501/6 "2020-06-10T08:16:38Z")

</div>

Hi Yuri,

danke für das Erstellen. Ich hab die zip Datei heruntergeladen und an das Ticket gehangen. Die Jungs aus dem Shopware 5 werden sich dann anschauen.

Viele Grüße aus Schöppingen

![cool](http://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/shopware.png "cool")&nbsp;Michael Telgmann
