-
Improvement
-
Resolution: Done
-
Minor
-
None
-
4.3.1, 4.4
-
MOODLE_403_STABLE, MOODLE_404_STABLE
https://php.watch/versions/8.3/php-ini-envar-fallback-value-syntax
PHP Supports substituting PHP INI values with Environment variables with PHP's string interpolation syntax. If the specified Environment variable is not available, the INI parser uses an empty string. In PHP 8.3, this syntax is extended to support declaring a fallback value if the Environment variable is not set.
session.name = ${SESSION_NAME}
|
sendmail_from = "${MAIL_FROM_USER}@${MAIL_FROM_DOMAIN}"
|
ini_get('session.name');
|
ini_get('sendmail_from');
|
All of the PHP versions support the syntax above to use Environment variables in PHP INI files. In this instance, the session.name INI value will be set to the SESSION_NAME Environment variable if set, or an empty string otherwise. The sendmail_from value uses string interpolation, and PHP substitutes the available Environment variables along with the @ character in the middle.
PHP does not emit any warnings at startup or parse time when the Environment variables are not present, and always substitutes it with an empty string.
PHP 8.3 extends the support for INI Environment variable substitution with support for declaring a fallback value.
In PHP 8.3 and later, it is possible to optionally declare a fallback value with the :- symbol, followed by the fallback value. The same INI values declared in the snippet above can now be set with fallback values:
session.name = ${SESSION_NAME:-Foo}
|
sendmail_from = "${MAIL_FROM_USER:-info}@${MAIL_FROM_DOMAIN:-example.com}"
|
ini_get('session.name');
|
ini_get('sendmail_from');
|
PHP 8.3 parses these values with support for fallback values specified after the :- symbol.
For example, the session.name value will be the value of the SESSION_NAME Environment variable if it is set, but it now uses Foo value otherwise.
sendmail_from value will also fall back to info@example.com if both MAIL_FROM_USER and MAIL_FROM_DOMAIN Environment variables are not set. If either of them are available, the Environment variable will be used.
Required
- Confirm my assessment that no change is required
- has a non-specific relationship to
-
MDL-80144 Validation only: Confirm a collection of PHP 8.3 issues are no-op
-
- Closed
-