Skip to content

Commit

Permalink
Fixed --memory-limit=-1 option handling when used in parallel (#6349)
Browse files Browse the repository at this point in the history
* Fixed --memory-limit=-1 option handling when used in parallel

* Escaped shell option value for the special case of --memory-limit
  • Loading branch information
ddegasperi authored Oct 3, 2024
1 parent c0c7502 commit 374bca2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Parallel/Command/WorkerCommandLineFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,15 @@ private function mirrorCommandOptions(InputInterface $input, array $mainCommandO
continue;
}

$workerCommandOptions[] = self::OPTION_DASHES . $mainCommandOptionName;
$workerCommandOptions[] = escapeshellarg($optionValue);
if ($mainCommandOptionName === 'memory-limit') {
// symfony/console does not accept -1 as value without assign
$workerCommandOptions[] = self::OPTION_DASHES . $mainCommandOptionName . '=' . \escapeshellarg(
$optionValue
);
} else {
$workerCommandOptions[] = self::OPTION_DASHES . $mainCommandOptionName;
$workerCommandOptions[] = \escapeshellarg($optionValue);
}
}

return $workerCommandOptions;
Expand Down
10 changes: 10 additions & 0 deletions tests/Parallel/Command/WorkerCommandLineFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ public static function provideData(): Iterator
],
"'" . PHP_BINARY . "' '" . self::DUMMY_MAIN_SCRIPT . "' '" . $cliInputOptionsAsString . "' worker --debug --xdebug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi",
];

yield [
[
self::COMMAND => 'process',
Option::SOURCE => ['src'],
'--' . Option::OUTPUT_FORMAT => ConsoleOutputFormatter::NAME,
'--' . Option::MEMORY_LIMIT => '-1',
],
"'" . PHP_BINARY . "' '" . self::DUMMY_MAIN_SCRIPT . "' '" . $cliInputOptionsAsString . "' worker --memory-limit='-1' --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi",
];
}

private function prepareProcessCommandDefinition(): InputDefinition
Expand Down

0 comments on commit 374bca2

Please sign in to comment.