php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51536 Add sapi binary location to php ini search path
Submitted: 2010-04-12 00:06 UTC Modified: 2010-05-01 22:44 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: ksingla@php.net Assigned: pajoye (profile)
Status: Wont fix Package: *Configuration Issues
PHP Version: 5.4 OS: Windows
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-04-12 00:06 UTC] ksingla@php.net
Description:
------------
PHP searches php.ini in the binary location which is retrieved using GetModuleFileName (first parameter to GetModuleFileName is NULL). This will return path to current *executable* which won't be path to php sapi binary in case of dlls. For IIS, location of w3wp.exe which is %windir%\system32\inetsrv\ will be added to php ini search path. Is this intentional? Can we change this code to make it look for php.ini in the folder where php sapi binary is present? Without this fix, users running non-cgi SAPIs are required to set PHPRC environment variable or IniFilePath registry key to make PHP pick php.ini in the php install folder.

If this bug is fixed, windows installer can stop setting PHPRC path to [installdir] and will be able to support side-by-side (SxS) install of PHP 5.2 and PHP 5.3. For installer to support SxS install, this change is required in PHP 5.2 and PHP 5.3. 

If we are worried about this being breaking change, we can just *add* php sapi binary location to php ini search path.


Patches

inipath_patch53 (last revision 2010-05-01 18:33 UTC by ksingla@php.net)
define_phpdll_patch_53 (last revision 2010-05-01 18:31 UTC by ksingla@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-12 10:54 UTC] pajoye@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: pajoye
 [2010-04-12 10:54 UTC] pajoye@php.net
hi,

Yes, ini location detection is not so good right now and needs to be improved.

However it has nothing to do with SxS per se. It is not need for FastCGI as one can use php-cgi.exe -c c:\phpxxx\php.ini. The installer could do that automatically, to support multiple install of the same versions (per site configuaration) or multiple install of various versions.

I don't think we will and can make change this behavior in 5.2. Please note that SxS support won't be done for 5.2, trunk will have it, whatever will be this version.
 [2010-04-12 23:44 UTC] ksingla@php.net
Yes, the fix is not needed for FastCGI but it is required for SAPIs which compile as dlls. Installer currently sets PHPRC environment variable at system level. To make different versions of PHP pick different php.ini in a SxS environment, it should stop creating PHPRC environment variable. Without PHPRC, SAPIs which are dlls won't be able to reach correct php.ini without this bug fix. This fix will be required in both PHP 5.2 and PHP 5.3 so that both versions don't have dependency on PHPRC. If one version requires PHPRC and installer sets it for that version, other version is going to pick php.ini from location specified by PHPRC unless we make PHP look for php.ini in SAPI binary location first. I understand that we want to keep locations specified by PHPRC and IniFilePath higher priority than SAPI binary folder. Given this, can this be fixed for both PHP 5.2 and PHP 5.3?
 [2010-04-13 01:06 UTC] pajoye@php.net
As I said in my first comment I don't think we can make this change in 5.2 or 5.3. However we could have alternative solutions. I will take a 2nd look at this problem (there is another report about the ini path priorities).

But again, what's the deal with SxS and 5.2/5.3? We can't do that either.
 [2010-05-01 20:31 UTC] ksingla@php.net
The following patch has been added/updated:

Patch Name: define_phpdll_patch_53
Revision:   1272738705
URL:        http://bugs.php.net/patch-display.php?bug=51536&patch=define_phpdll_patch_53&revision=1272738705
 [2010-05-01 20:33 UTC] ksingla@php.net
The following patch has been added/updated:

Patch Name: inipath_patch53
Revision:   1272738781
URL:        http://bugs.php.net/patch-display.php?bug=51536&patch=inipath_patch53&revision=1272738781
 [2010-05-01 21:00 UTC] pajoye@php.net
-Status: Assigned +Status: Wont fix
 [2010-05-01 21:00 UTC] pajoye@php.net
See my previous comment. Let make it clear(er) now.
 [2010-05-01 21:11 UTC] ksingla@php.net
-Status: Wont fix +Status: Re-Opened -PHP Version: 5.2.13 +PHP Version: 5.4
 [2010-05-01 21:11 UTC] ksingla@php.net
I don't understand why we can't make this fix in PHP 5.3. Anyway, we should atleast fix this in the trunk. Changed php version to 5.4.
 [2010-05-01 21:27 UTC] pajoye@php.net
-Status: Re-Opened +Status: Wont fix
 [2010-05-01 21:27 UTC] pajoye@php.net
For one, 5.3 code base is in bug fixes mode only (you changed the version to 5.3 just now).

Adding yet another path to look for php.ini is not something we like to do. Especially as there are clean and working solutions for both the Apache SAPI (PhpIniPath) and FastCGI (-c). I will put the specs John and I discussed in the wiki as well, so we have a good base to discuss.

Now, please don't reopen this report.
 [2010-05-01 21:47 UTC] ksingla@php.net
As I explained before, problem with PhpIniPath is that it affects all versions of PHP on the machine. So it cannot be used to point to different php.inis for different versions of PHP. Yes, this bug fix is not required for FastCGI.

If php ini search path doesn't contain the folder where php5.dll is present, I would consider it a bug and should be fixed in the branch which is accepting bug fixes.
 [2010-05-01 22:44 UTC] pajoye@php.net
PhpIniDir is set in your apache conf. It affects only this instance of Apache. And as only one version can be loaded at the same time.

For any other supported SAPIs on Windows (CLI, FastCGI), the -c can be used.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 20:01:28 2024 UTC