1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 20:10:08 +02:00

🐛 Use php_ini_scanned_files for .ini scan

Using `php-config --ini-dir` seems to fail on PHP 7.2 and below, likely
because said option was not available in these earlier versions. Because
all we need are the additional .ini files, calling php_ini_scanned_files
is a better solution since it is supported from PHP 5 and up.

This commit fixes the crash issue that was caused by running the failing
`php-config` command.

More information: https://www.php.net/manual/en/function.php-ini-scanned-files.php
This commit is contained in:
2021-04-19 10:25:55 +02:00
parent 327125608a
commit a0c6753761

View File

@ -43,15 +43,15 @@ class PhpInstallation {
post_max_size: Self.getByteCount(key: "post_max_size")
)
// Determine which folder(s) to scan for additional files
let iniFolder = Command.execute(path: Paths.phpConfig, arguments: ["--ini-dir"], trimNewlines: true)
// Return a list of .ini files parsed after php.ini
let paths = Command.execute(path: Paths.php, arguments: ["-r", "echo php_ini_scanned_files();"])
.replacingOccurrences(of: "\n", with: "")
.split(separator: ",")
.map { String($0) }
// Check the contents of the ini dir
let enumerator = FileManager.default.enumerator(atPath: URL(fileURLWithPath: iniFolder).path)
let filePaths = enumerator?.allObjects as! [String]
filePaths.filter { $0.contains(".ini") }.forEach { (iniFileName) in
let extensions = PhpExtension.load(from: URL(fileURLWithPath: "\(iniFolder)/\(iniFileName)"))
// See if any extensions are present in said .ini files
paths.forEach { (iniFilePath) in
let extensions = PhpExtension.load(from: URL(fileURLWithPath: iniFilePath))
if extensions.count > 0 {
self.extensions.append(contentsOf: extensions)
}