Skip to content

Commit

Permalink
ACMS-3658: The drs:init:settings command shouldn't be called when DRS…
Browse files Browse the repository at this point in the history
… updated.
  • Loading branch information
vishalkhode1 committed Mar 26, 2024
1 parent e6bdca0 commit f991017
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
*/
protected mixed $settingsPackage = NULL;

/**
* Checks if acquia/blt is updated.
*/
protected bool $bltUpdated = FALSE;

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -97,7 +102,7 @@ public function onPostPackageEvent(PackageEvent $event): void {
public function onPostCmdEvent(): void {
// Only install the template files, if the drupal-recommended-settings
// plugin is installed, with drupal project.
if ($this->settingsPackage && $this->getDrupalRoot()) {
if ($this->settingsPackage && $this->getDrupalRoot() && !$this->bltUpdated) {
$vendor_dir = $this->composer->getConfig()->get('vendor-dir');
$this->executeCommand(
$vendor_dir . "/bin/drush drs:init:settings", [],
Expand All @@ -119,8 +124,8 @@ protected function getSettingsPackage(OperationInterface $operation): mixed {
if ($operation instanceof InstallOperation) {
$package = $operation->getPackage();
}
elseif ($operation instanceof UpdateOperation) {
$package = $operation->getTargetPackage();
elseif ($operation instanceof UpdateOperation && $operation->getTargetPackage() instanceof PackageInterface) {
$this->bltUpdated = ($operation->getTargetPackage()->getName() == "acquia/blt");
}
if (isset($package) && $package instanceof PackageInterface && $package->getName() == "acquia/drupal-recommended-settings") {
return $package;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/unit/PluginUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function testGetSettingsPackage(): void {
$this->plugin->onPostPackageEvent($package_event);
$method = $this->getReflectionMethod(Plugin::class, "getSettingsPackage");
$package_name = $method->invokeArgs($this->plugin, [$operation]);
$this->assertEquals("acquia/drupal-recommended-settings-1.0", $package_name);
$this->assertNull($package_name);

// Assert when any other package is installed.
$package = new RootPackage("acquia/blt", "14.0", "14.0.0");
Expand Down

0 comments on commit f991017

Please sign in to comment.