| @@ -34,13 +34,18 @@ | ||
| 34 | 34 | |
| 35 | 35 | return $values; |
| 36 | 36 | }, 10, 2); |
| 37 | 37 | |
| 38 | - // Boot the module if active | |
| 39 | - $isActive = ModuleSettings::isActive('turnstile'); | |
| 40 | - | |
| 41 | - if ($isActive) { | |
| 42 | - (new TurnstileBoot())->register(); | |
| 43 | - } | |
| 38 | + // Boot the module if active. | |
| 39 | + // Deferred to `init` on purpose: ModuleSettings::getAllSettings() memoizes on its | |
| 40 | + // first call, and that is where `module_setting/default_values` is applied. Reading | |
| 41 | + // settings here would freeze the cache before modules registered later in | |
| 42 | + // Hooks/actions.php add their own defaults, leaving those modules permanently | |
| 43 | + // inactive. Every module must read settings after registration has finished. | |
| 44 | + add_action('init', function () { | |
| 45 | + if (ModuleSettings::isActive('turnstile')) { | |
| 46 | + (new TurnstileBoot())->register(); | |
| 47 | + } | |
| 48 | + }, 1); | |
| 44 | 49 | } |
| 45 | 50 | } |
| 46 | 51 | |