]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Hook.php
Merge pull request #11015 from MrPetovan/task/10979-frio-time-tooltip
[friendica.git] / src / Core / Hook.php
index 851dd60ed945277a2c86a9c8addd41c313aaf428..81c5d882dc1b6688219e4e057e3d2229491c39f9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -218,7 +218,7 @@ class Hook
                } else {
                        // remove orphan hooks
                        $condition = ['hook' => $name, 'file' => $hook[0], 'function' => $hook[1]];
-                       self::delete($condition, ['cascade' => false]);
+                       self::delete($condition);
                }
        }
 
@@ -247,14 +247,19 @@ class Hook
        /**
         * Deletes one or more hook records
         *
+        * We have to clear the cached routerDispatchData because addons can provide routes
+        *
         * @param array $condition
-        * @param array $options
         * @return bool
         * @throws \Exception
         */
-       public static function delete(array $condition, array $options = [])
+       public static function delete(array $condition)
        {
-               $result = DBA::delete('hook', $condition, $options);
+               $result = DBA::delete('hook', $condition);
+
+               if ($result) {
+                       DI::cache()->delete('routerDispatchData');
+               }
 
                return $result;
        }
@@ -262,6 +267,8 @@ class Hook
        /**
         * Inserts a hook record
         *
+        * We have to clear the cached routerDispatchData because addons can provide routes
+        *
         * @param array $condition
         * @return bool
         * @throws \Exception
@@ -270,6 +277,10 @@ class Hook
        {
                $result = DBA::insert('hook', $condition);
 
+               if ($result) {
+                       DI::cache()->delete('routerDispatchData');
+               }
+
                return $result;
        }
 }