On Monday, 2 March 2026 at 19:54, Christian Schneider <[email protected]> wrote:
> Am 02.03.2026 um 20:12 schrieb Tim Düsterhus <[email protected]>: > > On 3/2/26 14:49, Christian Schneider wrote: > >> Playing my favourite broken record: > >> Can we please state that additions of Exceptions should (in most cases) go > >> through an E_WARNING phase to allow a time window to fix code before > >> changing the behaviour? > > > > “Not passing invalid values” is perfectly backwards compatible. Folks can > > just fix their code before upgrading their production deployment to the new > > PHP version, e.g. by trying out the new PHP version in a staging system or > > running CI for both the old and new PHP version. > > - Not everybody has access to a staging system, e.g. people running stuff on > hosting services. > - As a hoster I'd rather have a phase where my customers get warnings instead > of errors, creates less emergency support load. > > > In practice an E_WARNING is no less breaking than going straight to an > > Error, because: > > 1. The common frameworks include error handlers that just convert any > > warning and notice to an Exception. > > So in that sense there is also no advantage to NOT having a warning phase for > those people. > But people treating E_WARNING different from Exceptions (which is probably > the exact people whose code breaks with an immediate Exception) do have a > time window to fix things. > > > 2. The code is already broken, because it relies on unspecified behavior. > > The error would just making the user aware that the code is very likely not > > doing what it appears to be doing based on the input values passed to a > > function. > > It can easily do something valid and ignore the extra bits (pun kind of > intended), see > mkdir("foo", 070777); > which passes extra bits with are ignored but the application was behaving in > a completely deterministic and valid way. > > > Going through an E_WARNING would add maintainer busywork and complicate the > > php-src codebase for no real gain. > > We've been over this before: > If people *really* feel that the additional burden to change the code twice > then I'd be happy to volunteer providing a small helper function/macro to > generate an E_WARNING and either (the more aggressive approach) switch to an > exception once a certain PHP version is reached or (probably the more > flexible way) issue a compile time warning/error informing the maintainer to > switch the warning to an Exception. > The most simplistic version of this is a FIXME comment annotated with a > version number. Easy to grep, easy to trigger automatic alerts about once the > specified version is reached, but it can also be something more > sophisticated.. > One way or the other could also be integrated into the CI/CD system. > > Our main disagreement is about the "no real gain" part as it IMHO targets the > long tail of PHP code / developers out there not using full-fledged > frameworks and dev environments or running legacy software on hosting > services. > > I am very much in favor of making things easy for the code developers but I > am of the strong believe that it can be done in a good way for developers. I don't see how going through an E_WARNING phase is helpful, rather I see it as detrimental. Foremost, what is the behaviour of introducing a warning? Do we exit early and return false? Or do we just warn and continue to use a possible default or nonsensical value? AFAIK every time a warning got introduced it followed the first approach, so this doesn't seem to address the concern of giving developers more time. However, if we do continue using the prior behaviour then we haven't solved the concern in the slightest. As it may be a warning for one PHP version and in the next PHP version the extension supports a new flag which removes the warning for that value, leading back to a silent BC break if the warning wasn't addressed. Another technical aspect is that warnings allows userland code to run and change the state of the VM and extension in unexpected way (we have countless fuzzying reports about this) an issue that does not exist with Exceptions. Then comes the topic about how long should it be a warning? Until the next major? A single release cycle? I don't want warning promotion to become the same exhausting discussion that deprecation duration already is. I have no idea how you handle hosting, but when I used shared hosting in the past I would never have anyone tell me that my code was producing warnings or notices. And even the one website I manage for someone which is on OVH shared hosting I can still select a PHP version (heck even downgrading to 5.4 for some reason). So I'm struggling to see how for the average end user this is impacting them? And if you do just bump the PHP version for them, I'm not sure what's the difference between having an Error immediately or producing warnings for X years before throwing an Error and breaking Best regards, Gina P. Banyard
