Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What did PHP's y2k_compliance php.ini setting do?

This question is purely for academic purposes, as the setting was removed in PHP 5.4 and the year 2000 is long past, but does anyone know what the y2k-compliance configration setting did?

The PHP documentation doesn't tell you much:

y2k_compliance (boolean)

Enforce year 2000 compliance (will cause problems with non-compliant browsers)

So, not much useful information there!

From a Google search, which mostly turned up repeats of the above or references to the setting's removal, the only additional information I found was this page, which states:

Some users may be using wildly outdated, noncompliant browsers. If for some bizarre reason you're sure that a number of your site's users fall into this group, then disable the y2k_compliance parameter; otherwise, it should be enabled.

y2k_compliance = On

Specifies whether or not the PHP script should be made year-2000 compliant. Making the PHP script Y2K compliant (by setting this directive to On) will cause problems with non-Y2K-compliant browsers.

A bit more information, but still a very high-level description.

I have been unable to find any technical information about what problem this setting was trying to solve or how it went about solving it.

So, what did PHP do differently if the y2k-compliance flag was disabled?

like image 523
HappyDog Avatar asked Aug 10 '19 20:08

HappyDog


1 Answers

Well, isn't that a blast from the past! I haven't seen this one for at least 10 years.

The behaviour is simple and actually easily trackable back to the source code. It only really affects one part of the PHP engine.

The crux of it is simple. RFC 850 (1983) specified that all date formats should have the last two digits of the date. RFC 822 changed this. However, this didn't mean that all browsers magically updated or even knew how to handle this.

For this reason, this flag was added, so people could set at will whether they wanted the old format, or the new one, based on how many users they had running old (at the time) browsers.

like image 150
Sébastien Renauld Avatar answered Sep 28 '22 20:09

Sébastien Renauld