A #PHP global constant redefinition is a simple warning.
A #PHP class constant redefinition is a full Fatal Error.
I am so used to the Fatal error, that I expected the global constant to behave the same. Shouldn't they?
[#]phptip #phptrick
https://php-tips.readthedocs.io/en/latest/tips/constant_redefinition.html
=> More informations about this toot | More toots from dseguy@phpc.social
@dseguy Fanatical dedication to backwards compatibility, innit? I susect there was concern over breaking WP or something.
=> More informations about this toot | More toots from pollita@phpc.social
@pollita It would leave a lot of WP installations unusable. And hinder further upgrades...
Because blaming the shitty BC policy of the PHP-team is much easier than fixing shitty code and check whether a constant is already defined before redefining it...
/cc @dseguy
=> More informations about this toot | More toots from heiglandreas@phpc.social
@heiglandreas @pollita @dseguy I’m not sure I’ve seen this particular code in wide spread use in WP. I could be wrong but it’s not a typical pattern in WP plugins or core.
=> More informations about this toot | More toots from skc@scottodon.com
@skc Checking whether a constant is already defined before defining it?
/cc @pollita @dseguy
=> More informations about this toot | More toots from heiglandreas@phpc.social
@heiglandreas @pollita @dseguy yeah that’s the normal practice I’ve seen, checking to see if it’s defined before defining it
=> More informations about this toot | More toots from skc@scottodon.com
@skc I've seen enough logfiles that showed, that it is not handled like that everywhere 😁
/cc @pollita @dseguy
=> More informations about this toot | More toots from heiglandreas@phpc.social
@heiglandreas @skc @pollita I measure (very roughly) about 1 out of 3 project defining global constants. And even more checking their existence.
It might be worth checking a number of those usages, to see actual usage, it might be interesting.
=> More informations about this toot | More toots from dseguy@phpc.social This content has been proxied by September (ba2dc).Proxy Information
text/gemini