Ancestors

Written by dseguy on 2024-12-26 at 15:12

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

=> View attached media

=> More informations about this toot | More toots from dseguy@phpc.social

Written by Sara Golemon on 2024-12-26 at 15:24

@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

Written by Alerta! Alerta! on 2024-12-26 at 15:32

@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

Written by SKC on 2024-12-26 at 15:36

@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

Written by Alerta! Alerta! on 2024-12-26 at 15:38

@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

Toot

Written by SKC on 2024-12-26 at 17:03

@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

Descendants

Written by Alerta! Alerta! on 2024-12-26 at 17:06

@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

Written by dseguy on 2024-12-26 at 17:41

@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

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113720204178034874
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
325.324157 milliseconds
Gemini-to-HTML Time
1.381501 milliseconds

This content has been proxied by September (ba2dc).