Skip to content

Commit 21e8a0a

Browse files
fiskandig
authored andcommitted
Add better logging for disabled PCNTL extensions (php-pm#371)
1 parent 379a324 commit 21e8a0a

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

bin/ppm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,17 @@ if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader
1818
);
1919
}
2020

21+
if (!PHPPM\pcntl_installed()) {
22+
die(
23+
sprintf(
24+
'PCNTL is not enabled in the PHP installation at %s. See: http://php.net/manual/en/pcntl.installation.php',
25+
PHP_BINARY
26+
)
27+
);
28+
}
29+
2130
if (!PHPPM\pcntl_enabled()) {
22-
die('Some of required pcntl functions are disabled. Check `disable_functions` setting in `php.ini`.');
31+
die('Some required PCNTL functions are disabled. Check `disabled_functions` in `php.ini`.');
2332
}
2433

2534
use Symfony\Component\Console\Application;

src/ProcessManager.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,9 +1095,20 @@ protected function newSlaveInstance($port)
10951095
require_once file_exists($dir . '/vendor/autoload.php')
10961096
? $dir . '/vendor/autoload.php'
10971097
: $dir . '/../../autoload.php';
1098+
1099+
if (!pcntl_installed()) {
1100+
error_log(
1101+
sprintf(
1102+
'PCNTL is not enabled in the PHP installation at %s. See: http://php.net/manual/en/pcntl.installation.php',
1103+
PHP_BINARY
1104+
)
1105+
);
1106+
exit();
1107+
}
10981108
10991109
if (!pcntl_enabled()) {
1100-
throw new \RuntimeException('Some of required pcntl functions are disabled. Check `disable_functions` setting in `php.ini`.');
1110+
error_log('Some required PCNTL functions are disabled. Check `disabled_functions` in `php.ini`.');
1111+
exit();
11011112
}
11021113
11031114
//global for all global functions

src/functions.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,17 @@ function console_log($expression, $_ = null)
3030
}
3131

3232
/**
33-
* Checks that all required pcntl functions are available, so not fatal errors would be cause in runtime
33+
* Checks that PCNTL is actually enabled in this installation.
34+
*
35+
* @return bool
36+
*/
37+
function pcntl_installed()
38+
{
39+
return function_exists('pcntl_signal');
40+
}
41+
42+
/**
43+
* Makes sure required PCNTL functions aren't included in disable_functions.
3444
*
3545
* @return bool
3646
*/

0 commit comments

Comments
 (0)