php INI file reader parses "Off" as ""

Bug #1734786 reported by Vasya Pupkin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
php
Unknown
Unknown
php-defaults (Ubuntu)
Triaged
Wishlist
Unassigned

Bug Description

If I put "session.use_trans_sid = Off" in php.ini, the actual value of session.use_trans_sid becomes empty, which breaks functionality. For example, you can't put anything into your cart in Opencart CMS. Issue can be reproduced with console php:

[Test Case]
$ sudo apt install php-cli
$ echo "session.use_trans_sid = Off" > .user.ini
$ php -c .user.ini -r 'echo "session.use_trans_sid = \"".ini_get("session.use_trans_sid")."\"\n";'
session.use_trans_sid = ""

When "0" is used instead of "Off", everything works properly:

$ cat .user.ini
session.use_trans_sid = 0
$ php -c .user.ini -r 'echo "session.use_trans_sid = \"".ini_get("session.use_trans_sid")."\"\n";'
session.use_trans_sid = "0"

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: php (not installed)
ProcVersionSignature: Ubuntu 4.4.0-101.124-generic 4.4.95
Uname: Linux 4.4.0-101-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.13
Architecture: amd64
Date: Tue Nov 28 02:40:42 2017
InstallationDate: Installed on 2011-04-14 (2419 days ago)
InstallationMedia: Ubuntu-Server 10.04.2 LTS "Lucid Lynx" - Release amd64 (20110211.1)
SourcePackage: php-defaults
UpgradeStatus: Upgraded to xenial on 2016-07-30 (485 days ago)

Revision history for this message
Vasya Pupkin (shadowlmd) wrote :
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I believe it's this issue upstream, filed in 2010: https://bugs.php.net/bug.php?id=52168

Changed in php-defaults (Ubuntu):
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Vasya Pupkin (shadowlmd) wrote :

This is not that bug. The problem here is with setting value, not with getting it.

Revision history for this message
Vasya Pupkin (shadowlmd) wrote :

And I believe that PHP, when parsing ini, is reading value as INT instead of BOOL, that is why "off" leads to an empty value instead of 0. It also displays the value as INT in phpinfo(), i.e. 1/0 instead of On/Off.

Bryce Harrington (bryce)
description: updated
Revision history for this message
Bryce Harrington (bryce) wrote :

I think I agree with Andreas that it does indeed look like that same bug report. There is also a dupe bug that describes the issue more closely to how it's described in this one:

    https://bugs.php.net/bug.php?id=54051

> This is not that bug. The problem here is with setting value, not with getting it.

There may be misunderstanding, the 'get' is the function to read and interpret the value you set in the config file. So, 'get' from the computer's perspective, not from ours. :-)

Also, I think the behavior is not incorrect, even if it appears to be so. For example, if you set to "On", the value switches:

    triage-kinetic+22.10:~$ cat .user.ini
    session.use_trans_sid = On
    triage-kinetic+22.10:~$ php -c .user.ini -r 'echo "session.use_trans_sid = \"".ini_get("session.use_trans_sid")."\"\n";'
    session.use_trans_sid = "1"

Upstream's comment on the aforementioned bug report explains what's going on:

"Yes, this isn't completely consistent. An empty string is the same as Off. It
doesn't display the same as the boolean flags in phpinfo() because it isn't a
boolean since it can take numeric values. 0, "" and Off all mean the same thing
here. So it is purely aesthetic, but we should still go through and clean this up
at some point."

So, it's a known issue upstream, behaviorally correct if aesthetically awkward. I don't think this is something we'd need to address locally in Ubuntu, and would recommend engaging upstream for a fix.

Changed in php-defaults (Ubuntu):
importance: Low → Wishlist
tags: added: kinetic
summary: - session.use_trans_sid value parsed incorrectly
+ php INI file reader parses "Off" as ""
Revision history for this message
Bryce Harrington (bryce) wrote :

Btw, you mentioned in the original bug that having this read as "" causes a break in functionality for Opencart CMS. I might suggest that there could be a different issue involved there, and if you're still reproducing it, that it would be better to report the actual broken behavior to Opencart CMS and see if they can give a better diagnosis and assist in getting it reported to the right upstream component.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.