1
0
mirror of https://github.com/flarum/core.git synced 2025-07-24 18:21:33 +02:00

chore(package-manager): config composer to use web php version

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
This commit is contained in:
Sami Mazouz
2022-09-15 11:07:08 +01:00
parent f6761843b2
commit fd196454a5
3 changed files with 11 additions and 9 deletions

View File

@@ -9,6 +9,7 @@
namespace Flarum\PackageManager\Composer;
use Composer\Config;
use Composer\Console\Application;
use Flarum\Foundation\Paths;
use Flarum\PackageManager\OutputLogger;
@@ -70,4 +71,9 @@ class ComposerAdapter
return new ComposerOutput($exitCode, $output);
}
public static function setPhpVersion(string $phpVersion)
{
Config::$defaultConfig['platform']['php'] = $phpVersion;
}
}

View File

@@ -11,6 +11,7 @@ namespace Flarum\PackageManager\Job;
use Flarum\Bus\Dispatcher;
use Flarum\PackageManager\Command\BusinessCommandInterface;
use Flarum\PackageManager\Composer\ComposerAdapter;
use Flarum\Queue\AbstractJob;
use Illuminate\Queue\Middleware\WithoutOverlapping;
use Throwable;
@@ -23,11 +24,11 @@ class ComposerCommandJob extends AbstractJob
protected $command;
/**
* @var int[]
* @var string
*/
protected $phpVersion;
public function __construct(BusinessCommandInterface $command, array $phpVersion)
public function __construct(BusinessCommandInterface $command, string $phpVersion)
{
$this->command = $command;
$this->phpVersion = $phpVersion;
@@ -36,12 +37,7 @@ class ComposerCommandJob extends AbstractJob
public function handle(Dispatcher $bus)
{
try {
if ([PHP_MAJOR_VERSION, PHP_MINOR_VERSION] !== [$this->phpVersion[0], $this->phpVersion[1]]) {
$webPhpVersion = implode('.', $this->phpVersion);
$sshPhpVersion = implode('.', [PHP_MAJOR_VERSION, PHP_MINOR_VERSION]);
throw new \Exception("PHP version mismatch. SSH PHP version must match web server PHP version. Found SSH (PHP $sshPhpVersion) and Web Server (PHP $webPhpVersion).");
}
ComposerAdapter::setPhpVersion($this->phpVersion);
$this->command->task->start();

View File

@@ -73,7 +73,7 @@ class Dispatcher
$command->task = $task;
$this->queue->push(
new ComposerCommandJob($command, [PHP_MAJOR_VERSION, PHP_MINOR_VERSION])
new ComposerCommandJob($command, PHP_VERSION)
);
} else {
$data = $this->bus->dispatch($command);