Просмотр исходного кода

Fix: #3352 Unable to install Drupal (#3353)

Due to requirements for PHP8.1 we installing composer dependencies
Jaap Marcus 3 лет назад
Родитель
Сommit
71ca950d9f

+ 8 - 6
web/src/app/System/HestiaApp.php

@@ -117,7 +117,7 @@ class HestiaApp {
 		$this->runUser("v-run-cli-cmd", ["composer", "selfupdate", "--$version"]);
 	}
 
-	public function runComposer($args, &$cmd_result = null, $version = 2): bool {
+	public function runComposer($args, &$cmd_result = null, $data = []): bool {
 		$composer =
 			$this->getUserHomeDir() .
 			DIRECTORY_SEPARATOR .
@@ -125,15 +125,17 @@ class HestiaApp {
 			DIRECTORY_SEPARATOR .
 			"composer";
 		if (!is_file($composer)) {
-			$this->installComposer($version);
+			$this->installComposer($data["version"]);
 		} else {
-			$this->updateComposer($version);
+			$this->updateComposer($data["version"]);
+		}
+		if (empty($data["php_version"])) {
+			$data["php_version"] = "";
 		}
-
 		if (!empty($args) && is_array($args)) {
-			array_unshift($args, "composer");
+			array_unshift($args, "php" . $data["php_version"], $composer);
 		} else {
-			$args = ["composer", $args];
+			$args = ["php" . $data["php_version"], $composer, $args];
 		}
 
 		return $this->runUser("v-run-cli-cmd", $args, $cmd_result);

+ 7 - 1
web/src/app/WebApp/Installers/BaseSetup.php

@@ -104,7 +104,13 @@ abstract class BaseSetup implements InstallerInterface {
 			}
 
 			if ($res_type === "composer") {
-				new ComposerResource($this->appcontext, $res_data, $resource_destination);
+				$res_data["php_version"] = $options["php_version"];
+				new ComposerResource(
+					$this->appcontext,
+					$res_data,
+					$resource_destination,
+					$options["php_version"],
+				);
 			} elseif ($res_type === "wp") {
 				new WpResource(
 					$this->appcontext,

+ 5 - 2
web/src/app/WebApp/Installers/Drupal/DrupalSetup.php

@@ -38,8 +38,11 @@ class DrupalSetup extends BaseSetup {
 	public function install(array $options = null): bool {
 		parent::install($options);
 		parent::setup($options);
-
-		$this->appcontext->runComposer(["require", "-d " . $this->getDocRoot(), "drush/drush:^10"]);
+		$this->appcontext->runComposer(
+			["require", "-d " . $this->getDocRoot(), "drush/drush"],
+			$status2,
+			["version" => 2, "php_version" => $options["php_version"]],
+		);
 
 		$htaccess_rewrite = '
 <IfModule mod_rewrite.c>

+ 1 - 1
web/src/app/WebApp/Installers/Resources/ComposerResource.php

@@ -27,7 +27,7 @@ class ComposerResource {
 				$this->project,
 			],
 			$status,
-			$data["version"],
+			$data,
 		);
 
 		if ($status->code !== 0) {