Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"phpmailer/phpmailer": "7.*",
"phpoption/phpoption": "*",
"predis/predis": "*",
"rosell-dk/exec-with-fallback": "*",
"rosell-dk/webp-convert": "*",
"secondnetwork/blade-tabler-icons": "^3.46",
"simplepie/simplepie": "1.*",
Expand Down
5 changes: 2 additions & 3 deletions core/src/Console/Packages/ExtrasCommand.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php namespace EvolutionCMS\Console\Packages;

use Doctrine\DBAL\Exception;
use ExecWithFallback\ExecWithFallback;
use Illuminate\Console\Command;
use \EvolutionCMS;
use Illuminate\Support\Facades\File;

class ExtrasCommand extends Command
Expand Down Expand Up @@ -870,7 +869,7 @@ protected function runArtisanCommand(array $args)
foreach ($args as $arg) {
$command .= ' ' . escapeshellarg($arg);
}
passthru($command);
ExecWithFallback::exec($command);
}

protected function normalizeComposerVersion($version, array $branches = [], $defaultBranch = '')
Expand Down
5 changes: 3 additions & 2 deletions core/src/Console/SiteUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use EvolutionCMS\Models\SiteModule;
use EvolutionCMS\Services\ComposerVersionSynchronizer;
use EvolutionCMS\Services\Store\RemoteTransportService;
use ExecWithFallback\ExecWithFallback;
use Illuminate\Console\Command;

/**
Expand Down Expand Up @@ -986,7 +987,7 @@ protected function shellCommandExists(string $command): bool
? 'where ' . escapeshellarg($command) . ' >NUL 2>NUL'
: 'command -v ' . escapeshellarg($command) . ' >/dev/null 2>&1';

exec($probe, $output, $exitCode);
ExecWithFallback::exec($probe, $output, $exitCode);

return (int) $exitCode === 0;
}
Expand All @@ -1009,7 +1010,7 @@ protected function normalizeUpdateRepository(string $repository): string
protected function runCoreShellCommand(string $command): void
{
$fullCommand = 'cd ' . escapeshellarg(EVO_CORE_PATH) . ' && ' . $command . ' 2>&1';
exec($fullCommand, $output, $exitCode);
ExecWithFallback::exec($fullCommand, $output, $exitCode);

if ((int) $exitCode !== 0) {
$message = 'Command failed: ' . $command;
Expand Down
49 changes: 26 additions & 23 deletions install/cli-install.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use ExecWithFallback\ExecWithFallback;
use EvolutionCMS\Facades\Console;

$base_path = dirname(__DIR__) . '/';
Expand Down Expand Up @@ -33,6 +34,30 @@ function runCliInstall(array $argv): void

class InstallEvo
{
/**
* Run Composer update through the ExecWithFallback library.
*
* This replaces the previous manual fallback chain (passthru → exec → shell_exec)
* with the unified ExecWithFallback::exec() which automatically tries methods in order:
* exec() → passthru() → popen() → proc_open() → shell_exec() → Exception.
*
* @return void
*/
protected function runComposerUpdate(string $cmd): void
{
$out = [];
$exitCode = 0;
try {
ExecWithFallback::exec($cmd, $out, $exitCode);
if (!empty($out) && is_array($out)) {
echo implode(PHP_EOL, $out), PHP_EOL;
}
} catch (\Exception $e) {
info('- No command execution methods available (all disabled).');
warning('⚠ Run "composer update" manually.');
}
}

public $typeInstall = '';
public $databaseType = '';
public $databaseServer = '';
Expand Down Expand Up @@ -455,7 +480,6 @@ public function composerUpdate()
return;
}

$disabled = array_map('trim', explode(',', ini_get('disable_functions') ?: ''));
$composerBin = EVO_CORE_PATH . 'vendor/bin/composer';
$workingDir = EVO_CORE_PATH;

Expand All @@ -472,28 +496,7 @@ public function composerUpdate()
escapeshellarg($workingDir)
);

$exitCode = null;
if (!in_array('passthru', $disabled, true)) {
passthru($cmd, $exitCode);
} elseif (!in_array('exec', $disabled, true)) {
exec($cmd . ' 2>&1', $out, $exitCode);
echo implode(PHP_EOL, $out), PHP_EOL;
} elseif (!in_array('shell_exec', $disabled, true)) {
$output = shell_exec($cmd . ' 2>&1');
$exitCode = (is_string($output) && $output !== '') ? 0 : 1;
echo $output;
} else {
info('- The passthru/exec/shell_exec functions are disabled in php.ini.');
warning('⚠ Run "composer update" manually.');
return;
}

if ($exitCode === 0) {
success('✔ Dependencies updated successfully.');
} else {
error("✖ Composer finished with the code {$exitCode}.");
warning('⚠ Make sure you have execute permissions and try "composer update" manually.');
}
$this->runComposerUpdate($cmd);
}

public function realInstall()
Expand Down
8 changes: 5 additions & 3 deletions manager/actions/bkmanager.static.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
EvolutionCMS()->webAlertAndQuit($_lang["error_no_privileges"]);
}

use ExecWithFallback\ExecWithFallback;

$dbase = EvolutionCMS()->getDatabase()->getConfig('database');

if (!EvolutionCMS()->getConfig('snapshot_path')) {
Expand Down Expand Up @@ -44,7 +46,7 @@
file_put_contents($tempfile_path, file_get_contents($_FILES['sqlfile']['tmp_name']));

$dump_request = 'PGPASSWORD="'.EvolutionCMS()->getDatabase()->getConfig('password').'" psql --host '.EvolutionCMS()->getDatabase()->getConfig('host').' --username ' . EvolutionCMS()->getDatabase()->getConfig('username') . ' --dbname ' . $dbase . ' < '.$tempfile_path;
exec($dump_request, $data, $data_second);
ExecWithFallback::exec($dump_request, $data, $data_second);
unlink($tempfile_path);
break;
default:
Expand All @@ -61,7 +63,7 @@
switch ($driver) {
case 'pgsql':
$dump_request = 'PGPASSWORD="'.EvolutionCMS()->getDatabase()->getConfig('password').'" psql --host '.EvolutionCMS()->getDatabase()->getConfig('host').' --username ' . EvolutionCMS()->getDatabase()->getConfig('username') . ' --dbname ' . $dbase . ' < '.$path;
exec($dump_request, $data, $data_second);
ExecWithFallback::exec($dump_request, $data, $data_second);
break;
default :
import_sql_from_file($path);
Expand Down Expand Up @@ -99,7 +101,7 @@

$dump_request = 'pg_dump postgresql://' . EvolutionCMS()->getDatabase()->getConfig('username') . ':'.EvolutionCMS()->getDatabase()->getConfig('password').'@'.EvolutionCMS()->getDatabase()->getConfig('host').'/' . $dbase . ' --clean --inserts --no-owner --no-privileges '. $table_str .'> ' . $tempfile_path;

exec($dump_request, $data, $data_second);
ExecWithFallback::exec($dump_request, $data, $data_second);
dumpSql($tempfile_path);
break;
case 'sqlite':
Expand Down