fix validate using non-builtin functions too early (#11436)

* fix validate using non-builtin functions too early
This commit is contained in:
Tony Murray
2020-04-18 10:55:48 -05:00
committed by GitHub
parent 1c08c11a77
commit 6576a6c807

View File

@@ -13,7 +13,6 @@
* the source code distribution for details.
*/
use Illuminate\Support\Str;
use LibreNMS\Config;
use LibreNMS\ValidationResult;
use LibreNMS\Validator;
@@ -82,18 +81,18 @@ if (!file_exists('config.php')) {
$pre_checks_failed = false;
$syntax_check = `php -ln config.php`;
if (!Str::contains($syntax_check, 'No syntax errors detected')) {
if (strpos($syntax_check, 'No syntax errors detected') === false) {
print_fail('Syntax error in config.php');
echo $syntax_check;
$pre_checks_failed = true;
}
$first_line = rtrim(`head -n1 config.php`);
if (!Str::startsWith($first_line, '<?php')) {
if (!strpos($first_line, '<?php') === 0) {
print_fail("config.php doesn't start with a <?php - please fix this ($first_line)");
$pre_checks_failed = true;
}
if (Str::contains(`tail config.php`, '?>')) {
if (strpos(`tail config.php`, '?>') !== false) {
print_fail("Remove the ?> at the end of config.php");
$pre_checks_failed = true;
}