Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Apr 21, 2024
2 parents c2da959 + 971b0da commit b82cfc7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
__DIR__ . '/.php-cs-fixer.no-header.php',
__DIR__ . '/.php-cs-fixer.tests.php',
__DIR__ . '/.php-cs-fixer.user-guide.php',
__DIR__ . '/preload.php',
__DIR__ . '/rector.php',
__DIR__ . '/spark',
]);
Expand Down
22 changes: 6 additions & 16 deletions preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@
// Path to the front controller
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR);

/**
* See https://www.php.net/manual/en/function.str-contains.php#126277
*/
if (! function_exists('str_contains')) {
/**
* Polyfill of str_contains()
*/
function str_contains(string $haystack, string $needle): bool
{
return empty($needle) || strpos($haystack, $needle) !== false;
}
}

class preload
{
/**
Expand All @@ -51,6 +38,7 @@ class preload
[
'include' => __DIR__ . '/vendor/codeigniter4/framework/system', // Change this path if using manual installation
'exclude' => [
'/system/bootstrap.php',
// Not needed if you don't use them.
'/system/Database/OCI8/',
'/system/Database/Postgre/',
Expand All @@ -77,16 +65,18 @@ public function __construct()
$this->loadAutoloader();
}

private function loadAutoloader()
private function loadAutoloader(): void
{
$paths = new Config\Paths();
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'Boot.php';

CodeIgniter\Boot::preload($paths);
}

/**
* Load PHP files.
*/
public function load()
public function load(): void
{
foreach ($this->paths as $path) {
$directory = new RecursiveDirectoryIterator($path['include']);
Expand Down
13 changes: 13 additions & 0 deletions system/Boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ public static function bootTest(Paths $paths): void
static::autoloadHelpers();
}

/**
* Used by `preload.php`
*/
public static function preload(Paths $paths): void
{
static::definePathConstants($paths);
static::loadConstants();
static::defineEnvironment();
static::loadEnvironmentBootstrap($paths, false);

static::loadAutoloader();
}

/**
* Load environment settings from .env files into $_SERVER and $_ENV
*/
Expand Down
5 changes: 3 additions & 2 deletions system/Security/CheckPhpIni.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ public static function checkIni(): array
$ini = ini_get_all();

foreach ($items as $key => $values) {
$hasKeyInIni = array_key_exists($key, $ini);
$output[$key] = [
'global' => $ini[$key]['global_value'],
'current' => $ini[$key]['local_value'],
'global' => $hasKeyInIni ? $ini[$key]['global_value'] : 'disabled',
'current' => $hasKeyInIni ? $ini[$key]['local_value'] : 'disabled',
'recommended' => $values['recommended'] ?? '',
'remark' => $values['remark'] ?? '',
];
Expand Down

0 comments on commit b82cfc7

Please sign in to comment.