Skip to content

Commit 9df972c

Browse files
authored
Merge pull request #110 from tinect/fixPhpIniGetFailover
fix: php ini with value 0 misinterpreted, added helper function
2 parents 9e529ae + b9eff8a commit 9df972c

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

src/Components/Health/Checker/PerformanceChecker/PhpSettingsChecker.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function collect(HealthCollection $collection): void
2020

2121
private function checkAssertActive(HealthCollection $collection, string $url): void
2222
{
23-
$currentValue = \ini_get('assert.active');
23+
$currentValue = $this->iniGetFailover('assert.active');
2424
if ($currentValue !== '0') {
2525
$collection->add(
2626
SettingsResult::warning('frosh-tools.checker.AssertActiveWarning',
@@ -44,7 +44,7 @@ private function checkAssertActive(HealthCollection $collection, string $url): v
4444

4545
private function checkEnableFileOverride(HealthCollection $collection, string $url): void
4646
{
47-
$currentValue = \ini_get('opcache.enable_file_override') ?: 'not set';
47+
$currentValue = $this->iniGetFailover('opcache.enable_file_override');
4848
if ($currentValue !== '1') {
4949
$collection->add(
5050
SettingsResult::warning('frosh-tools.checker.EnableFileOverrideWarning',
@@ -68,7 +68,7 @@ private function checkEnableFileOverride(HealthCollection $collection, string $u
6868

6969
private function checkInternedStringsBuffer(HealthCollection $collection, string $url): void
7070
{
71-
$currentValue = \ini_get('opcache.interned_strings_buffer') ?: 'not set';
71+
$currentValue = $this->iniGetFailover('opcache.interned_strings_buffer');
7272
if ((int) $currentValue < 20) {
7373
$collection->add(
7474
SettingsResult::warning('frosh-tools.checker.InternedStringsBufferWarning',
@@ -92,11 +92,11 @@ private function checkInternedStringsBuffer(HealthCollection $collection, string
9292

9393
private function checkZendDetectUnicode(HealthCollection $collection, string $url): void
9494
{
95-
$currentValue = \ini_get('zend.detect_unicode') ?: 'not set';
95+
$currentValue = $this->iniGetFailover('zend.detect_unicode');
9696
if ($currentValue !== '0') {
9797
$collection->add(
9898
SettingsResult::warning('frosh-tools.checker.ZendDetectUnicodeWarning',
99-
$currentValue,
99+
(string) $currentValue,
100100
'0',
101101
$url
102102
)
@@ -116,7 +116,7 @@ private function checkZendDetectUnicode(HealthCollection $collection, string $ur
116116

117117
private function checkRealpathCacheTtl(HealthCollection $collection, string $url): void
118118
{
119-
$currentValue = \ini_get('realpath_cache_ttl') ?: 'not set';
119+
$currentValue = $this->iniGetFailover('realpath_cache_ttl');
120120
if ((int) $currentValue < 3600) {
121121
$collection->add(
122122
SettingsResult::warning('frosh-tools.checker.RealpathCacheTtlWarning',
@@ -137,4 +137,14 @@ private function checkRealpathCacheTtl(HealthCollection $collection, string $url
137137
)
138138
);
139139
}
140+
141+
private function iniGetFailover(string $option): string
142+
{
143+
$currentValue = \ini_get($option);
144+
if (\is_string($currentValue)) {
145+
return $currentValue;
146+
}
147+
148+
return 'not set';
149+
}
140150
}

0 commit comments

Comments
 (0)