A few months ago I updated my PHP version. PHP 5.4 to 5.5 . I never had any problems updating PHP before. I follow its development closely and try to remove my deprecated functions long before they are officially removed. But this time I was caught off guard. It silently broke part of my website for the silliest reason.
I did the update at night before going to bed and only tested my homepage on my local machine before I turned it off. A few days later, I try to access my website and it seems to be broken.
PHP Fatal error: Call to undefined function json_decode().
JSON decode is not defined? How is that even possible? Was it removed from the source code? I thought maybe I had deleted something by mistake, or the update was interrupted somehow. So I removed PHP and reinstalled it. Nada!
It was still broken. Maybe this function was deprecated and I am the last man on earth still trying to use it. There was nothing unusual I could find inside phpinfo(). So I went to Google. Well, it looked like I was not alone.
“[...] if you had upgraded from the version provided by php.net you would not have seen a problem. We have not removed json and we will never release a version of php without json support built in. Any changes in 5.5 is due to whatever distro packaging you are using which we have no control over.” &mdash Rasmus Lerdorf.
There is nothing technically wrong with json_decode. In fact, it is still as amazing in PHP 5.5. The problem is the most childish thing I ever read in my life.
I use Ubuntu as my operating system, and it obeys the Free Software Foundation definition of Free Software:
The freedom to run the program as you wish, for any purpose (freedom 0).
This doesn't cause any problem of course, until someone comes in and tries to be funny about it.
The Software shall be used for Good, not Evil.
According to the Free Software Foundation, JSON is not free (even though it is free). It just has this silly statement. But rules are rules, so if you download your PHP upgrade from any distro obeying this license, JSON support will not be included.
So what do you do? You install the damn thing manually:
sudo apt-get install php5-json
It is at most silly. I never had to do anything when I update my PHP code before. This one sure reminded me that we are only human, that sometimes we fight over stupid things. By the way, removing the json extension caused other bugs, so they had to fix that too.
Other than that, PHP 5.5 has some cool new feature that I will not be talking about because you probably don't care. But read here anyway
Original Bug report:
Hi, This statement in the JSON extensions source code worries Debian about complience with the Debian free software guide (DFSG). It would be great to remove this paragraph as to be clean the first license paragraph is obviously free software license. ./ext/json/utf8_to_utf16.c:The Software shall be used for Good, not Evil. ./ext/json/JSON_parser.c:The Software shall be used for Good, not Evil. ./ext/json/utf8_decode.c:The Software shall be used for Good, not Evil. ./README.REDIST.BINS:The Software shall be used for Good, not Evil.