Bug 630635

Summary: Add [PHP] section to all parsed extension ini files
Product: [Fedora] Fedora Reporter: Fabian Grutschus <f.grutschus>
Component: phpAssignee: Remi Collet <fedora>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 13CC: fedora, f.grutschus, jorton, pahan, redhat, rpm
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
URL: http://www.php.net/ini.sections
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-09-11 05:52:50 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Reset ini hash before "each" file in php.d none

Description Fabian Grutschus 2010-09-06 13:14:43 UTC
Description of problem: Fedora uses /etc/php.d for loading PHP extensions and Zend extension through ini files. If someone uses PHPs ini sections (see http://www.php.net/ini.sections) inside an own ini file in /etc/php.d or in /etc/php.ini this will prevent extension from loading.

The PHP manual says:
"These sections are used only in CGI/FastCGI mode and they can not set extension and zend_extension directives."
So extension= and zend_extension= needs to be under [PHP].


Version-Release number of selected component: PHP 5.3.3-1

Steps to Reproduce:
1. Use PHP over Apache/Lighttpd as CGI
2. Add [PATH=] or [HOST=] to /etc/php.ini (or an own file at /etc/php.d)
3. See phpinfo() for loaded extensions
4. extensions loaded at /etc/php.d won't be loaded
  
Actual results:
For example the widely used pdo extension (/etc/php.d/pdo.ini):
; Enable pdo extension module
extension=pdo.so


Expected results:
[PHP]
; Enable pdo extension module
extension=pdo.so

Additional info: http://www.php.net/manual/en/ini.sections.php#99780

Comment 1 Remi Collet 2010-09-06 16:58:11 UTC
Verified
# php -m | wc -l 
73  
# echo "[PATH=/usr]" >/etc/php.d/test.ini
# php -m | wc -l
65  

Fix seems trivial, but imply to fix all extension .ini files
- from php main package
- from all php-pecl-package
  16 packages
- from other php extensions 
  cups-php
  graphviz-php
  ice-php
  nntpgrab-php
  php-facedetect
  php-libpuzzle
  php-magickwand
  php-mapip
  php-shout
  rrdtool-php
  syck-php
  uuid-php
From   repoquery --whatprovides '/etc/php.d/*.ini' :

Is it really a change needed when is so simple to simply add [PATH=xx] and [HOST=xx] in the last ini file, (/etc/php.d/z-myhost.ini, p.e.) ?

Joe ?

Comment 2 Remi Collet 2010-09-06 17:05:04 UTC
It could be useful to file an upstream bug on php project to ask to "reset" the section on each new ini file...

Comment 3 Joe Orton 2010-09-06 17:26:58 UTC
From reading the code the section *is* reset to default before reading /etc/php.d so it should not be the case that any section in /etc/php.ini affects the php.d files in any way.  Only the latter case of adding a section to a php.d ini file.

This is trivial to fix in the code (move down the RESET_ACTIVE_INI_HASH() macro) and that is probably appropriate rather than changing our ini files, unless upstream disagree.

Comment 4 Fabian Grutschus 2010-09-06 18:22:48 UTC
That's not true, I tested it:
[root@homebox crash]# php -m | wc -l
54
[root@homebox crash]# echo "[PATH=/usr]" >> /etc/php.ini 
[root@homebox crash]# php -m | wc -l
32

I'll create a bug entry at bugs.php.net to clarify this bug.

Comment 5 Remi Collet 2010-09-06 18:36:35 UTC
Created attachment 443350 [details]
Reset ini hash before "each" file in php.d

The attached patch fixes the describe issue
- reset ini hash before "each" file in php.d
- fix RESET_ACTIVE_INI_HASH (to also reset is_special_section)

Comment 6 Remi Collet 2010-09-06 18:40:03 UTC
@Fabian : what you describe in comment #4 is link to the need to also reset "is_special_section".

Comment 7 Fabian Grutschus 2010-09-06 18:42:43 UTC
Remi Collet: thanks for the fast fix. I've reported this to the PHP developers here: http://bugs.php.net/bug.php?id=52786

Comment 8 Remi Collet 2010-09-06 19:01:09 UTC
@Fabian : if you want to try the fix, please use the test build from http://rpms.famillecollet.com/fedora/13/test/x86_64/repoview/ (php-5.3.4-0.1.201009061630.fc13.remi).

Comment 9 Joe Orton 2010-09-06 19:01:52 UTC
Thanks for the patch, Remi; thanks to both of you for pushing this upstream.

Comment 10 Adam Harvey 2010-09-09 06:49:19 UTC
I've applied Remi's patch without change on the 5.3 branch and trunk.

Thanks for pushing the report up to us!

Comment 11 Remi Collet 2010-09-11 05:52:50 UTC
I close thid bug as upstream. 
The fix will be available in next release (5.3.4)