console-parallelization
console-parallelization copied to clipboard
Error when the server script name is an absolute path
With the current code:
$pwd = $_SERVER['PWD'];
$scriptName = $_SERVER['SCRIPT_NAME'];
return str_starts_with($scriptName, $pwd)
? $scriptName
: $pwd.DIRECTORY_SEPARATOR.$scriptName;
If the script name is absolute, e.g. /usr/local/bin/box, the resolved script name will be a nonsensical path.
I'm a pimcore user where this library is used e.g. to run the console commands for data-importer. Using that functionality I ran in exactly this issue with data import cron job which has absolute path for the script set. For me, running a Linux server, the following change did solve the issue (will be different for e.g. Windows):
private static function getScriptPath(): string
{
$pwd = $_SERVER['PWD'];
$scriptName = $_SERVER['SCRIPT_NAME'];
return (str_starts_with($scriptName, $pwd)
|| str_starts_with($scriptName, DIRECTORY_SEPARATOR))
? $scriptName
: $pwd.DIRECTORY_SEPARATOR.$scriptName;
}
@APochmann would you be open to do a PR with this patch?
Sure, but I do not have possibility to test on Windows system, tested only on my Linux system
That is ok, we don't own a windows machine either so this library has never really been tested on Windows. This could probably be done now by adding a Windows job to the pipeline since GA supports Windows, if someone wants to work on this