You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 95e2534
Browse filesBrowse the repository at this point in the historyBrowse files
perf: scan the environment once when building config classes (#10657)
* perf(#10615): scan the environment once when building config classes
`BaseConfig::__construct()` checked every leaf property against `$_ENV`,
`$_SERVER` and four `getenv()` calls, so the common no-override path was
also the slowest. The environment is now indexed once, grouped by the text
before the first "." or "_", and each class only walks the keys that match
its prefixes. The index is rebuilt when `$_ENV` or `$_SERVER` changes
(once per request in Worker Mode) or on `BaseConfig::reset()`.
PHP's `getenv()` array omits names containing ".", " " or "[", so those
are looked up with `getenv()` on each class's first build and cached for
the process. Classes that override `getEnvValue()` or `initEnvValue()`
keep the previous live lookups. Lookup precedence is unchanged.
Building 20 core config classes (PHP 8.3 CLI, no opcache, median):
| Scenario | Before | After |
|---------------------------------------|----------|----------|
| Warm, no overrides, new $_SERVER | 0.456 ms | 0.073 ms |
| Warm, no overrides, unchanged env | 0.456 ms | 0.031 ms |
| Warm, 5 overrides, new $_SERVER | 0.467 ms | 0.110 ms |
| Warm, 5 overrides, unchanged env | 0.471 ms | 0.067 ms |
| Cold first build, no overrides | 0.493 ms | 0.205 ms |
| Cold first build, 5 overrides | 0.505 ms | 0.267 ms |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(#10615): re-read live env vars on every config build
Cache only the names of env vars found with live getenv() calls, per
leaf, and re-read their values on each build, so removed or changed
values are not reused. Leaves first seen on a later instance are now
probed too. On Windows, probe the underscore forms live as well, so
they keep matching case-insensitively.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(#10615): probe underscore env names live under Apache mod_php
Under Apache mod_php, live getenv() reads SetEnv vars case-insensitively,
so `SetEnv APP_BASEURL` matched `app_baseURL` in 4.8, but the indexed
$_SERVER and getenv() array only hold the exact name. Probe the
underscore forms live on any SAPI not known to match names exactly,
keeping the cheaper path for CLI, FPM and FrankenPHP.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(#10615): clarify putenv() cache limits in Worker Mode
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: user_guide_src/source/changelogs/v4.8.0.rst
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,9 @@ Behavior Changes
69
69
- **Commands:** The ``worker:uninstall`` command now returns ``EXIT_SUCCESS`` (previously ``EXIT_ERROR``) when the user declines the interactive confirmation prompt, since user-initiated cancellation is not a failure. In non-interactive mode without ``--force`` it now aborts with ``EXIT_ERROR`` instead of prompting, and the redundant ``Uninstalling FrankenPHP Worker Mode`` header was dropped. Scripts that branch on the previous exit code or wording will need updating.
70
70
- **Commands:** The ``phpini:check`` command's invalid-argument error now prints only ``You must specify a correct argument.``. The usage example and the argument listing moved to ``phpini:check --help``, where the argument is now named ``section``. Scripts that grep the previous output will need updating.
71
71
- **Config:** ``CodeIgniter\Config\BaseService`` is now ``abstract``. It is intended to be extended (as ``Config\Services`` does) and accessed statically; code that instantiated it directly with ``new BaseService()`` will now throw an ``Error``.
72
+
- **Config:** ``BaseConfig`` now scans the environment once instead of checking every property against it, which makes building config classes
73
+
several times faster without config caching and in Worker Mode. As a result, a bare ``putenv()`` call (adding, changing, or removing a variable) made
74
+
after the first config class was built may not be seen until ``BaseConfig::reset()`` runs, including in later requests in Worker Mode. See :ref:`upgrade-480-config-env-lookups`.
72
75
- **Database:** The Postgre driver's ``$db->error()['code']`` previously always returned ``''``. It now returns the 5-character SQLSTATE string for query and transaction failures (e.g., ``'42P01'``), or ``'08006'`` for connection-level failures. Code that relied on ``$db->error()['code'] === ''`` will need updating.
73
76
- **Debug:** ``CodeIgniter\Debug\Toolbar\Collectors\BaseCollector`` is now ``abstract``. Custom toolbar collectors must extend it; code that instantiated it directly with ``new BaseCollector()`` will now throw an ``Error``.
74
77
- **Filters:** HTTP method matching for method-based filters is now case-sensitive. The keys in ``Config\Filters::$methods`` must exactly match the request method
0 commit comments