Skip to content

Commit c09a4e1

Browse files
committed
Fixed an issue where the PCRE JIT on PHP 7.3 caused PHPCS to die when using the parallel option (ref #2304)
1 parent dd3f6e0 commit c09a4e1

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

package.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
2727
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD 3-Clause License</license>
2828
<notes>
2929
- Squiz.Arrays.ArrayDeclaration now has improved handling of syntax errors
30+
- Fixed an issue where the PCRE JIT on PHP 7.3 caused PHPCS to die when using the parallel option
31+
-- PHPCS now disables the PCRE JIT before running
3032
- Fixed bug #2368 : MySource.PHP.AjaxNullComparison throws error when first function has no doc comment
3133
- Fixed bug #2414 : Indention false positive in switch/case/if combination
3234
- Fixed bug #2423 : Squiz.Formatting.OperatorBracket.MissingBrackets error with static

src/Runner.php

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ public function init()
293293
// be detected properly for files created on a Mac with the /r line ending.
294294
ini_set('auto_detect_line_endings', true);
295295

296+
// Disable the PCRE JIT as this caused issues with parallel running.
297+
ini_set('pcre.jit', false);
298+
296299
// Check that the standards are valid.
297300
foreach ($this->config->standards as $standard) {
298301
if (Util\Standards::isInstalledStandard($standard) === false) {
@@ -536,7 +539,10 @@ private function run()
536539
}//end if
537540
}//end for
538541

539-
$this->processChildProcs($childProcs);
542+
$success = $this->processChildProcs($childProcs);
543+
if ($success === false) {
544+
throw new RuntimeException('One or more child processes failed to run');
545+
}
540546
}//end if
541547

542548
restore_error_handler();
@@ -709,20 +715,35 @@ private function processChildProcs($childProcs)
709715
$numProcessed = 0;
710716
$totalBatches = count($childProcs);
711717

718+
$success = true;
719+
712720
while (count($childProcs) > 0) {
713721
foreach ($childProcs as $key => $procData) {
714722
$res = pcntl_waitpid($procData['pid'], $status, WNOHANG);
715723
if ($res === $procData['pid']) {
716724
if (file_exists($procData['out']) === true) {
717725
include $procData['out'];
718-
if (isset($childOutput) === true) {
719-
$this->reporter->totalFiles += $childOutput['totalFiles'];
720-
$this->reporter->totalErrors += $childOutput['totalErrors'];
721-
$this->reporter->totalWarnings += $childOutput['totalWarnings'];
722-
$this->reporter->totalFixable += $childOutput['totalFixable'];
723-
$this->reporter->totalFixed += $childOutput['totalFixed'];
726+
727+
unlink($procData['out']);
728+
unset($childProcs[$key]);
729+
730+
$numProcessed++;
731+
732+
if (isset($childOutput) === false) {
733+
// The child process died, so the run has failed.
734+
$file = new DummyFile(null, $this->ruleset, $this->config);
735+
$file->setErrorCounts(1, 0, 0, 0);
736+
$this->printProgress($file, $totalBatches, $numProcessed);
737+
$success = false;
738+
continue;
724739
}
725740

741+
$this->reporter->totalFiles += $childOutput['totalFiles'];
742+
$this->reporter->totalErrors += $childOutput['totalErrors'];
743+
$this->reporter->totalWarnings += $childOutput['totalWarnings'];
744+
$this->reporter->totalFixable += $childOutput['totalFixable'];
745+
$this->reporter->totalFixed += $childOutput['totalFixed'];
746+
726747
if (isset($debugOutput) === true) {
727748
echo $debugOutput;
728749
}
@@ -733,11 +754,6 @@ private function processChildProcs($childProcs)
733754
}
734755
}
735756

736-
unlink($procData['out']);
737-
unset($childProcs[$key]);
738-
739-
$numProcessed++;
740-
741757
// Fake a processed file so we can print progress output for the batch.
742758
$file = new DummyFile(null, $this->ruleset, $this->config);
743759
$file->setErrorCounts(
@@ -752,6 +768,8 @@ private function processChildProcs($childProcs)
752768
}//end foreach
753769
}//end while
754770

771+
return $success;
772+
755773
}//end processChildProcs()
756774

757775

0 commit comments

Comments
 (0)