Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128781 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 8EC1F1A00BC for ; Sun, 5 Oct 2025 12:55:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1759668831; bh=WNUvTq4uO5YpXiX0FryvUbCR8+iq8Ii0C1Fpnzt0+dA=; h=From:To:Subject:Date:References:From; b=SlBiCBIt7s1r0z/zdMj2zKumDy0EnLo7b1Q8BMptw4PxuAW1CFy6UtfDG7HYspI/P AiIOxQA5kjOq2QGERncvqwS6XaaXZfJWThCzqSK1qB++eq2pV9HWhcYTuyrNL6o0IB ZIHq6J/m6Fbukteo5wkQpeJtkGSqTnwYuYwEdZgLzKR/fMfwNOf3VWJeuY28i/wsHL F2I+88xQ/Xi6AiewC0XR3GWzkSTSvqXCnQ18oolw1FSlGH21DxMjEyH48hykxGVruB 7CAdq2i32EQlJ6zbM1oPnwrQ28P8NuCUaM5luhS1EiJlwbFQOAaIe2hhFnJdBFrC39 DWtT/nauF/4Fw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2218A18003F for ; Sun, 5 Oct 2025 12:53:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from sonic309-24.consmr.mail.ir2.yahoo.com (sonic309-24.consmr.mail.ir2.yahoo.com [77.238.179.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 5 Oct 2025 12:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1759668905; bh=/q0O+CVhl6XmcRrGYVtSfrBPEh7yzNQgHIU3nRQ6SyU=; h=From:To:Subject:Date:References:From:Subject:Reply-To; b=e4Dj+7MYDjxixItnqJ9MqN2E0u7p7JxdTiUO0Bipt+tPsBP0R4ihdqq7lZwlOmM3lMWxsI17Yph6vvtmbvLEHZG/VQmKZ92B5++9nq25SpPlu0gfAht8yfV2Q3EUVKyn9NR8OIgIMqY1giZiBqq06sPG0DUpE3VYHqcNJQx6aWzhP046h/NoTcfznq5+yyWTTFIMXR/YbCvB8bR0wC6FtJBl2Pnk7WEDUasKp6X4n1iqJxu0Xp6/6XYb6Yz44e+uFGNFhkB+P5vyW0KSFKm7e+gya/GNlGlsMvntru4tRhoHJ9c6Sst/nKbJyW7S07f4Iw6J+JU5UbkyLCN6a6MXeQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1759668905; bh=xMrZS6bYCPjv19qDd5ys6jwzfJgRXaTbIVcsDlRHLsH=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=j6qnSgZZkR4VLDd+Ppnvf1uGK3vdKIg4szaXK21odsaVBeT4n/kBjN3OhMNLz3egkHLSGG6YnwXuxryLnBgrSpHiSt823Isl28bSeoEh61AiP1Az0iyYlgWoRvjWmQgIHQKedQuNgoswSCGu3KMJpK5ygrS1sa0yYkuxgtfBd2nUSVwo9e9DoiSB+il4OIhsAsSQjVYVFPAjKD/zwCEH7mY5zU+SenDHj/7al6LSX5qLlhxOHtkjLu+Xj27dnEy18s4OHHg2dZd2nMPcVedlu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4x7udBIyn1KYq9nwjPA Tzfjp.WRiyvfEvh1FQgMzjW0qTCBqQCTguIW8MEk0iFAI5x5kz1GYyD7bdBp4nwvf1VMxBUyDgzW ncfWWBnxGlHd0Kh9.iVgRI0tCrehbnzq2PzRDr3p.InbFCaY9OnP_cRBxXYItXctyJg69CXGWkcJ WD.yvme0B6abZpVBsLyBlCH45rDuJUswSisp8Ksus2TYOonm_wrrBlLcUIu1K X-Sonic-MF: X-Sonic-ID: b28e2888-58d3-4da9-a6d5-7f8b5f9aa909 Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ir2.yahoo.com with HTTP; Sun, 5 Oct 2025 12:55:05 +0000 Received: by hermes--production-ir2-ccdb4f9c8-2l5bb (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 893370fb476df47f0c5bebe8e153b052; Sun, 05 Oct 2025 12:55:00 +0000 (UTC) Content-Type: multipart/alternative; boundary="----sinikael-?=_1-17596688999030.18495869788146002" Message-ID: <1759668599422.2126186334.2604999201@yahoo.de> To: internals@lists.php.net Subject: [PHP-DEV] Deprecate Undefined Constant Usage in php.ini Files (GH-20060) Date: Sun, 05 Oct 2025 12:54:59 +0000 X-Mailer: Vivaldi Mail User-Agent: Vivaldi Mail/7.6.3797.56 Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <1759668599422.2126186334.2604999201.ref@yahoo.de> From: hanskrentel@yahoo.de (Hans Krentel) ------sinikael-?=_1-17596688999030.18495869788146002 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hello list, I'd like to propose a change in PHP behaviour and would like to request your comments. Find my proposals' draft below. Thank you in advance for your attention and thoughts, as usual I can benefit from your help. If you have voting power and would consider to vote on the topic, your rejection or acceptance rationale appreciated. I would like to draft an implementation and could incorporate the feedback then beforehand already. Best, -- hakre ## Deprecate Undefined Constant Usage in php.ini Files The php.ini file parser (as used by `parse_ini_file()`) supports constant resolution, including core predefined constants. However, the current behavior with undefined constants is inconsistent with PHP 8's strict handling of undefined constants in regular PHP code. ### Problem Statement #### Current Inconsistent Behavior In PHP 8 scripts, undefined constants trigger immediate fatal errors: b.) The Configuration File c.) Core Predefined Constants #### 3v4l.org PHP Codes d.) https://3v4l.org/7PA3u Undefined constant e.) https://3v4l.org/vC6mg Unsupported operand types ------sinikael-?=_1-17596688999030.18495869788146002 Content-Type: text/html; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit
Hello list,
I'd like to propose a change in PHP behaviour and would like to 
request
your comments.

Find my proposals' draft below.

Thank you in advance for your attention and thoughts, as usual I can
benefit from your help. If you have voting power and would consider
to vote on the topic, your rejection or acceptance rationale
appreciated. I would like to draft an implementation and could
incorporate the feedback then beforehand already.

Best,

-- hakre


## Deprecate Undefined Constant Usage in php.ini Files

The php.ini file parser (as used by `parse_ini_file()`) supports
constant resolution, including core predefined constants. However, the
current behavior with undefined constants is inconsistent with PHP 8's
strict handling of undefined constants in regular PHP code.

### Problem Statement

#### Current Inconsistent Behavior

In PHP 8 scripts, undefined constants trigger immediate fatal errors:

<?php
$var = X_ERROR; // Fatal error: Undefined constant "X_ERROR"

However, in php.ini files, undefined constants are silently handled
using PHP 4-era semantics:

[PHP]
error_reporting = X_ERROR|E_WARNING|E_PARSE|E_NOTICE

This silently:

1. Converts `X_ERROR` to string `"X_ERROR"`
2. Converts that string to integer `0` in bitwise context
3. Results in value `14` (0 | 4 | 2 | 8) without any indication of the
error

This creates invisible configuration errors that are difficult to debug.

### Proposed Change

#### Proposal: Add Diagnostics for Undefined Constants

We propose emitting diagnostics when undefined constants are encountered
in configuration files:

**During startup (php.ini parsing):**


PHP: Use of undefined constant NAME_OF_CONSTANT - assumed 'NAME_OF_CONSTANT' (this will throw an Error in a future version of PHP)


**During runtime (parse_ini_file/string):**


PHP Warning: Use of undefined constant NAME_OF_CONSTANT - assumed 'NAME_OF_CONSTANT' (this will throw an Error in a future version of PHP) in filename on line X


This makes configuration errors visible and paves the way for future
strict handling.

### Message Severity Discussion

The proposed warning message and severity mirror the PHP 7.2 approach
for undefined constants in scripts:


Warning: Use of undefined constant UNDEFINED_CONSTANT - assumed 'UNDEFINED_CONSTANT' (this will throw an Error in a future version of PHP)


Alternative severity levels could be considered:

| Severity | Wording | Intent |
|--------------|--------------|---------------------|
| E_DEPRECATED | "may throw" | Softer transition |
| E_WARNING | "will throw" | Clear future intent |
| E_NOTICE | "will throw" | Less intrusive |

The PHP 7.2 precedent suggests E_WARNING is appropriate for this level
of issue.

### Benefits

- Early detection: Configuration errors become visible immediately
- Consistency: Aligns ini parsing behavior with PHP 8 language
semantics
- Fail-fast: Helps users identify and fix configuration mistakes sooner
- Future-proof: Enables eventual strict mode matching PHP script
behavior

### Implementation Notes

The change would be implemented in `zend_ini_get_constant()` by adding
diagnostics when constant resolution fails. The current `ini_error()`
function uses `ZEND_COLD` (compiler hint for infrequently executed
code), which remains appropriate since undefined constants should be
rare in production configurations.

This infrastructure would also support a future transition to throwing
Errors, though the error handling mechanism might need adjustment at
that time.

* Note: This section is preliminary and subject to implementation
* details.

### References

#### PHP Manual Pages

a.) parse_ini_file() <https://www.php.net/manual/en/function.parse-ini-file.php>
b.) The Configuration File <https://www.php.net/manual/en/configuration.file.php>
c.) Core Predefined Constants <https://www.php.net/manual/en/reserved.constants.php#reserved.constants.core>

#### 3v4l.org PHP Codes

d.) https://3v4l.org/7PA3u Undefined constant
e.) https://3v4l.org/vC6mg Unsupported operand types
------sinikael-?=_1-17596688999030.18495869788146002--