-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Hux patch to invalidate hook discovery w/ deployment identifier:
https://www.drupal.org/project/hux/issues/3302312#comment-15207542 Also removed the Hux discovery cache delete from .do/deploy-tasks.sh
- Loading branch information
1 parent
422dc0f
commit a2243f8
Showing
3 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,4 @@ | ||
#!/bin/bash | ||
|
||
# Delete the Hux discovery cache entry in case of hook changes. | ||
# | ||
# @see https://www.drupal.org/project/hux/issues/3302312#comment-15202523 | ||
drush php:eval "\Drupal::service('cache.bootstrap')->delete('hux.discovery');" | ||
|
||
# Run any necessary database updates. | ||
drush -y updb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
patches/drupal/hux/3302312-discovery-deployment-identifier.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
diff --git a/hux.services.yml b/hux.services.yml | ||
index 24fc9f8..4370f77 100644 | ||
--- a/hux.services.yml | ||
+++ b/hux.services.yml | ||
@@ -11,6 +11,7 @@ services: | ||
arguments: | ||
- '@hux.module_handler.inner' | ||
- '@cache.bootstrap' | ||
+ - '@settings' | ||
calls: | ||
- [ setContainer, [ '@service_container' ] ] | ||
tags: | ||
diff --git a/src/HuxModuleHandler.php b/src/HuxModuleHandler.php | ||
index 2c6955b..e5ad3f4 100644 | ||
--- a/src/HuxModuleHandler.php | ||
+++ b/src/HuxModuleHandler.php | ||
@@ -7,6 +7,7 @@ namespace Drupal\hux; | ||
use Drupal\Component\Utility\NestedArray; | ||
use Drupal\Core\Cache\CacheBackendInterface; | ||
use Drupal\Core\Extension\ModuleHandlerInterface; | ||
+use Drupal\Core\Site\Settings; | ||
use Symfony\Component\DependencyInjection\ContainerAwareTrait; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
|
||
@@ -53,10 +54,13 @@ final class HuxModuleHandler implements ModuleHandlerInterface { | ||
* The inner module handler. | ||
* @param \Drupal\Core\Cache\CacheBackendInterface $cacheBackend | ||
* A fast cache backend. | ||
+ * @param \Drupal\Core\Site\Settings | ||
+ * The site settings instance. | ||
*/ | ||
public function __construct( | ||
protected ModuleHandlerInterface $inner, | ||
protected CacheBackendInterface $cacheBackend, | ||
+ protected Settings $siteSettings, | ||
) { | ||
} | ||
|
||
@@ -285,6 +289,22 @@ final class HuxModuleHandler implements ModuleHandlerInterface { | ||
yield from $this->alters[$alter]; | ||
} | ||
|
||
+ /** | ||
+ * Get the Hux discovery cache key. | ||
+ * | ||
+ * @return string | ||
+ * | ||
+ * @see \Drupal\Core\DrupalKernel::getContainerCacheKey() | ||
+ * This is how core uses the deployment identifier to automatically rebuild | ||
+ * the container. | ||
+ */ | ||
+ private function getHuxDiscoveryCacheKey(): string { | ||
+ return \implode(':', [ | ||
+ 'hux.discovery', | ||
+ $this->siteSettings->get('deployment_identifier'), | ||
+ ]); | ||
+ } | ||
+ | ||
/** | ||
* Initialises and caches, or unserializes discovery. | ||
* | ||
@@ -299,14 +319,15 @@ final class HuxModuleHandler implements ModuleHandlerInterface { | ||
public function discovery(ContainerInterface $container, array $implementations, array $huxParameters): void { | ||
['optimize' => $optimize] = $huxParameters; | ||
$optimize ?? throw new \Exception('Missing Hux parameters. App is misconfigured.'); | ||
- if ($optimize && ($cache = $this->cacheBackend->get('hux.discovery'))) { | ||
+ $cacheKey = $this->getHuxDiscoveryCacheKey(); | ||
+ if ($optimize && ($cache = $this->cacheBackend->get($cacheKey))) { | ||
$this->discovery = $cache->data; | ||
} | ||
else { | ||
$this->discovery = new HuxDiscovery($implementations); | ||
$this->discovery->discovery($container); | ||
if ($optimize) { | ||
- $this->cacheBackend->set('hux.discovery', $this->discovery); | ||
+ $this->cacheBackend->set($cacheKey, $this->discovery); | ||
} | ||
} | ||
} |