php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60179 php_flag and php_value does not work properly
Submitted: 2011-10-31 08:43 UTC Modified: 2011-11-03 15:48 UTC
From: dbetz at df dot eu Assigned: fat (profile)
Status: Closed Package: FPM related
PHP Version: 5.3.8 OS: Gentoo Linux
Private report: No CVE-ID: None
 [2011-10-31 08:43 UTC] dbetz at df dot eu
Description:
------------
Hello,

when setting php_flag to Off or false, then PHP FPM sets it to the string "Off" rather than 0 or NULL.

In fpm.conf
php_flag["session.auto_start"] = Off
or
php_flag["session.auto_start"] = false

It seems that the failure is on all boolean flags.


Test script:
---------------
<?
echo "session.auto_start is : " . ini_get('session.auto_start') . "\n";
if (ini_get('session.auto_start')) {
        echo "Some code here .....\n";
}
?>




Expected result:
----------------
session.auto_start is : 0

Actual result:
--------------
session.auto_start is : Off

Patches

fpm-bug60179-v2.patch (last revision 2011-11-03 15:07 UTC by fat@php.net)
fpm-bug60179.patch (last revision 2011-10-31 13:00 UTC by fat@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-31 13:00 UTC] fat@php.net
The following patch has been added/updated:

Patch Name: fpm-bug60179.patch
Revision:   1320066041
URL:        https://bugs.php.net/patch-display.php?bug=60179&patch=fpm-bug60179.patch&revision=1320066041
 [2011-10-31 13:02 UTC] fat@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: fat
 [2011-10-31 13:02 UTC] fat@php.net
Can you please test the patch attached ?

If you can test it quickly I can integrate it before 5.3.9 is going RC1.

thx
++ fat
 [2011-10-31 13:11 UTC] dbetz at df dot eu
-Status: Feedback +Status: Assigned
 [2011-10-31 13:11 UTC] dbetz at df dot eu
Hello,

sorry, the problem still exists.
session.auto_start is : Off
Some code here .....

With cli:
session.auto_start is : 0
 [2011-10-31 13:18 UTC] fat@php.net
1- On wich version did you apply the patch ? Please test the patch on the 
lastest 5.3.x snapshot.

2- you should not surrender the parameter with double quote:

php_flag["session.auto_start"] = Off

should be

php_flag[session.auto_start] = Off


Can you get rid of the bug. On my side, I have the last 5.3.x snapshot and it 
works great. I can't reproduce your problem.
 [2011-10-31 13:18 UTC] fat@php.net
-Status: Assigned +Status: Feedback
 [2011-10-31 13:52 UTC] dbetz at df dot eu
-Status: Feedback +Status: Assigned
 [2011-10-31 13:52 UTC] dbetz at df dot eu
Hi fat,

i have tested the latest snapshot with the patch and have changed the config to
php_flag[session.auto_start] = Off

But the problem is still here.

Looking into fpm_conf.c at: static char *fpm_conf_set_array(... :
        if (convert_to_bool) {
                char *err = fpm_conf_set_boolean(value, &subconf, 0);
                if (err) return err;
                kv->value = strdup(b ? "On" : "Off");
        }

It looks like kv->value is either string "On" or "Off" or am i wrong ?
 [2011-10-31 14:22 UTC] fat@php.net
hum ... not sure to understand your problem afterall :)

without the patch:
If I set php_flag[session.auto_start]=On
ini_get("session.auto_start") returns "On"
and session are created for each page (auto start is on as asked)

If I set php_flag[session.auto_start]=Off
ini_get("session.auto_start") returns "Off"
and session are NOT created for each page (auto start is off as asked)

For me this works as expected.
Do you have the same behavior ?
 [2011-10-31 14:34 UTC] dbetz at df dot eu
Hello,

yes, the option is set correct, but the return value of ini_get() is different than whith php-cgi.

Most apps like typo3, joomla, wordpress, eg. are checking in the installer, if php.ini settings are correct.
These setting are checked thru ini_get.

When ini_get(session.auto_start) is not 0 but "Off", then the check fails.

Here is the sample code from typo3 installer:

                if (ini_get('session.auto_start')) {
                        $sessionCreationError = 'Error: session.auto-start
is enabled.<br />';
                        $sessionCreationError .= 'The PHP option
session.auto-start is enabled. Disable this option in php.ini or
.htaccess:<br />';

I hope you understand now my problem.
 [2011-10-31 14:44 UTC] dbetz at df dot eu
In the php manual http://php.net/ini_get is an notice:
Hinweis: When querying boolean values

A boolean ini value of off will be returned as an empty string or "0" while a boolean ini value of on will be returned as "1". The function can also return the literal string of INI value. 

--

It looks like, that the value is not boolen Off but string "Off"
 [2011-11-03 15:07 UTC] fat@php.net
The following patch has been added/updated:

Patch Name: fpm-bug60179-v2.patch
Revision:   1320332822
URL:        https://bugs.php.net/patch-display.php?bug=60179&patch=fpm-bug60179-v2.patch&revision=1320332822
 [2011-11-03 15:08 UTC] fat@php.net
-Status: Assigned +Status: Feedback
 [2011-11-03 15:08 UTC] fat@php.net
I finally understood your problem ;)

Can you please test the version 2 of the patch attached and reopen the bug when 
it's done ?

Thx
++ Jerome
 [2011-11-03 15:13 UTC] dbetz at df dot eu
Hello Jerome,

works like a charm :-)

Thank you much.

Greetings,
Daniel
 [2011-11-03 15:13 UTC] dbetz at df dot eu
-Status: Feedback +Status: Assigned
 [2011-11-03 15:44 UTC] fat@php.net
-Summary: wrong output with php_flag boolean +Summary: php_flag and php_value does not work properly
 [2011-11-03 15:47 UTC] fat@php.net
Automatic comment from SVN on behalf of fat
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=318743
Log: - Fixed bug #60179 (php_flag and php_value does not work properly)
 [2011-11-03 15:48 UTC] fat@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

I've fixed 2 things:
1- php_flag didn't handle correctly the On and Off parameters
2- php_value didn't accept empty values
 [2011-11-03 15:48 UTC] fat@php.net
-Status: Assigned +Status: Closed
 [2012-04-18 09:48 UTC] laruence@php.net
Automatic comment on behalf of fat
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b4ccb69736190b42f0aa148344796856d1fecc87
Log: - Fixed bug #60179 (php_flag and php_value does not work properly)
 [2012-07-24 23:39 UTC] rasmus@php.net
Automatic comment on behalf of fat
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b4ccb69736190b42f0aa148344796856d1fecc87
Log: - Fixed bug #60179 (php_flag and php_value does not work properly)
 [2013-11-17 09:35 UTC] laruence@php.net
Automatic comment on behalf of fat
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b4ccb69736190b42f0aa148344796856d1fecc87
Log: - Fixed bug #60179 (php_flag and php_value does not work properly)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 09:01:30 2024 UTC