From 423ed7e10bf0d8623d0f1c51b490e2ed908e40cf Mon Sep 17 00:00:00 2001 From: Jon Simonsen Date: Mon, 9 Dec 2024 08:43:22 +0100 Subject: [PATCH 1/4] Add suggested PHP changes in drush and composer files --- drush/Commands/PolicyCommands.php | 1 + scripts/composer/ScriptHandler.php | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/drush/Commands/PolicyCommands.php b/drush/Commands/PolicyCommands.php index 790bbeb21..91e9b9320 100644 --- a/drush/Commands/PolicyCommands.php +++ b/drush/Commands/PolicyCommands.php @@ -37,4 +37,5 @@ public function rsyncValidate(CommandData $commandData) { throw new \Exception(dt('Per !file, you may never rsync to the production site.', ['!file' => __FILE__])); } } + } diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index b42759a67..61b6c7a91 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -1,10 +1,5 @@ exists($drupalRoot . '/'. $dir)) { - $fs->mkdir($drupalRoot . '/'. $dir); - $fs->touch($drupalRoot . '/'. $dir . '/.gitkeep'); + if (!$fs->exists($drupalRoot . '/' . $dir)) { + $fs->mkdir($drupalRoot . '/' . $dir); + $fs->touch($drupalRoot . '/' . $dir . '/.gitkeep'); } } - // Prepare the settings file for installation + // Prepare the settings file for installation. if (!$fs->exists($drupalRoot . '/sites/default/settings.php') && $fs->exists($drupalRoot . '/sites/default/default.settings.php')) { $fs->copy($drupalRoot . '/sites/default/default.settings.php', $drupalRoot . '/sites/default/settings.php'); require_once $drupalRoot . '/core/includes/bootstrap.inc'; @@ -55,7 +58,7 @@ public static function createRequiredFiles(Event $event) { $event->getIO()->write("Created a sites/default/settings.php file with chmod 0666"); } - // Create the files directory with chmod 0777 + // Create the files directory with chmod 0777. if (!$fs->exists($drupalRoot . '/sites/default/files') && !is_link($drupalRoot . '/sites/default/files')) { $oldmask = umask(0); $fs->mkdir($drupalRoot . '/sites/default/files', 0777); From 8e010477a7b3211712186ad320decbd06a3c79cb Mon Sep 17 00:00:00 2001 From: Jon Simonsen Date: Mon, 9 Dec 2024 08:45:15 +0100 Subject: [PATCH 2/4] Add suggested comment change in load.environment.php --- load.environment.php | 1 + 1 file changed, 1 insertion(+) diff --git a/load.environment.php b/load.environment.php index eb5e3a0f8..44b97f7ed 100644 --- a/load.environment.php +++ b/load.environment.php @@ -1,6 +1,7 @@ Date: Mon, 9 Dec 2024 10:19:02 +0100 Subject: [PATCH 3/4] Add class description for composer ScriptHandler. --- scripts/composer/ScriptHandler.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index 61b6c7a91..e71db32f2 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -10,7 +10,10 @@ use Symfony\Component\Filesystem\Filesystem; /** + * Handles various script events during the Composer lifecycle for Drupal projects. * + * This class provides static methods to create necessary files and directories + * for Drupal installations and checks for Composer version compatibility. */ class ScriptHandler { From 2a062aef8b104939bb33b534623844f9f188b7d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rn=20Fauske?= Date: Mon, 9 Dec 2024 10:24:11 +0100 Subject: [PATCH 4/4] Add description for ScriptHandler::createRequiredFiles() --- scripts/composer/ScriptHandler.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index e71db32f2..4e680803a 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -18,7 +18,15 @@ class ScriptHandler { /** + * Creates required Drupal directories and files to ensure proper installation. + * + * This method sets up necessary directories (`modules`, `profiles`, `themes`) + * and prepares essential configuration files like `settings.php`. It ensures + * these components are in place for successful Drupal setup and permissions + * are properly set for installation. + * * @param \Composer\Script\Event $event + * The event object for handling script events. * * @return void */