Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Us strpos() only
Signed-off-by: Git'Fellow <[email protected]>
  • Loading branch information
solracsf committed Nov 14, 2023
commit ef5f7d0a907a2864d39272f1b82b608fc0ef45fb
12 changes: 3 additions & 9 deletions lib/private/Preview/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,20 +257,14 @@ public static function unguardWithSemaphore(false|\SysvSemaphore $semId): bool {
*/
public static function getHardwareConcurrency(): int {
static $width;

if (!isset($width)) {
if (function_exists('ini_get')) {
$openBasedir = ini_get('open_basedir');
if ($openBasedir == '') {
if (empty($openBasedir) || strpos($openBasedir, '/proc/cpuinfo') !== false) {
$width = is_readable('/proc/cpuinfo') ? substr_count(file_get_contents('/proc/cpuinfo'), 'processor') : 0;
} else {
$openBasedirPaths = explode(':', $openBasedir);
foreach ($openBasedirPaths as $path) {
if (strpos($path, '/proc') === 0 || $path === '/proc/cpuinfo') {
$width = is_readable('/proc/cpuinfo') ? substr_count(file_get_contents('/proc/cpuinfo'), 'processor') : 0;
} else {
$width = 0;
}
}
$width = 0;
}
} else {
$width = 0;
Expand Down