Skip to content

Commit 71ca950

Browse files
authored
Fix: hestiacp#3352 Unable to install Drupal (hestiacp#3353)
Due to requirements for PHP8.1 we installing composer dependencies
1 parent e571216 commit 71ca950

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

web/src/app/System/HestiaApp.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,23 +117,25 @@ public function updateComposer($version) {
117117
$this->runUser("v-run-cli-cmd", ["composer", "selfupdate", "--$version"]);
118118
}
119119

120-
public function runComposer($args, &$cmd_result = null, $version = 2): bool {
120+
public function runComposer($args, &$cmd_result = null, $data = []): bool {
121121
$composer =
122122
$this->getUserHomeDir() .
123123
DIRECTORY_SEPARATOR .
124124
".composer" .
125125
DIRECTORY_SEPARATOR .
126126
"composer";
127127
if (!is_file($composer)) {
128-
$this->installComposer($version);
128+
$this->installComposer($data["version"]);
129129
} else {
130-
$this->updateComposer($version);
130+
$this->updateComposer($data["version"]);
131+
}
132+
if (empty($data["php_version"])) {
133+
$data["php_version"] = "";
131134
}
132-
133135
if (!empty($args) && is_array($args)) {
134-
array_unshift($args, "composer");
136+
array_unshift($args, "php" . $data["php_version"], $composer);
135137
} else {
136-
$args = ["composer", $args];
138+
$args = ["php" . $data["php_version"], $composer, $args];
137139
}
138140

139141
return $this->runUser("v-run-cli-cmd", $args, $cmd_result);

web/src/app/WebApp/Installers/BaseSetup.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ public function retrieveResources($options) {
104104
}
105105

106106
if ($res_type === "composer") {
107-
new ComposerResource($this->appcontext, $res_data, $resource_destination);
107+
$res_data["php_version"] = $options["php_version"];
108+
new ComposerResource(
109+
$this->appcontext,
110+
$res_data,
111+
$resource_destination,
112+
$options["php_version"],
113+
);
108114
} elseif ($res_type === "wp") {
109115
new WpResource(
110116
$this->appcontext,

web/src/app/WebApp/Installers/Drupal/DrupalSetup.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ class DrupalSetup extends BaseSetup {
3838
public function install(array $options = null): bool {
3939
parent::install($options);
4040
parent::setup($options);
41-
42-
$this->appcontext->runComposer(["require", "-d " . $this->getDocRoot(), "drush/drush:^10"]);
41+
$this->appcontext->runComposer(
42+
["require", "-d " . $this->getDocRoot(), "drush/drush"],
43+
$status2,
44+
["version" => 2, "php_version" => $options["php_version"]],
45+
);
4346

4447
$htaccess_rewrite = '
4548
<IfModule mod_rewrite.c>

web/src/app/WebApp/Installers/Resources/ComposerResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(HestiaApp $appcontext, $data, $destination) {
2727
$this->project,
2828
],
2929
$status,
30-
$data["version"],
30+
$data,
3131
);
3232

3333
if ($status->code !== 0) {

0 commit comments

Comments
 (0)