Reputation: 11
With php 7.2 I get the following error:
PHP Warning: A non-numeric value encountered in on line 234
Here is what line 234 looks like:
$options['cpuLimit'] + 1, # hard limit
Togehter with the rest of the code:
if ( php_uname( 's' ) == 'Linux' ) {
// Limit memory and CPU
$cmd = wfEscapeShellArg(
'exec', # proc_open() passes $cmd to 'sh -c' on Linux, so add an 'exec' to bypass it
'/bin/sh',
__DIR__ . '/lua_ulimit.sh',
$options['cpuLimit'], # soft limit (SIGXCPU)
$options['cpuLimit'] + 1, # hard limit
intval( $options['memoryLimit'] / 1024 ),
$cmd );
}
Anyone know how to fix the error?
Upvotes: 1
Views: 400
Reputation: 497
You can use intval() to get an integer from the value:
intval($options['cpuLimit']) + 1;
Before using intval you might want to check if that value is a number in the first place. You can do that with is_numeric();
if (is_numeric($options['cpuLimit']) == true) {
intval($options['cpuLimit']) + 1;
}
Source: PHP-intval PHP-is_numeric
Upvotes: 1