php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17516 overriding constants in config.w32.h.in
Submitted: 2002-05-29 16:52 UTC Modified: 2003-05-08 12:32 UTC
Votes:4
Avg. Score:4.5 ± 0.5
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: urs@php.net Assigned: ssb (profile)
Status: Closed Package: PEAR related
PHP Version: 4.3.2-RC OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: urs@php.net
New email:
PHP Version: OS:

 

 [2002-05-29 16:52 UTC] urs@php.net
While working with PEAR installer it occurred that the pear.ini setting file got placed in a newly created directory c:\php4. This dir is hardcoded in:

http://cvs.php.net/co.php/php4/main/config.w32.h.in

To respect other php installations like in c:\php or c:\programme\php one need a feature to override the constants given by the php core:

http://www.php.net/manual/en/reserved.constants.core.php

Since scripts in PEAR are designed using these constants, and constants are not variable, there is probably only one way to override these values in config.w32.h.in e.g. like:

#define PHP_SYSCONFDIR ( (getenv("PHP_SYSCONFDIR") != "c:\\php4" ) ? getenv("PHP_SYSCONFDIR" ) : "c:\\php4" )

This allows the user to configure its paths by hand through setting the environment variables like:

c:\>set PHP_SYSCONFDIR=c:\php

I propose to do this switch for all path related constants in config.w32.h.in [DIRECTORY_SEPARATOR, PHP_SYSCONFDIR, DEFAULT_INCLUDE_PATH, PEAR_INSTALL_DIR, PEAR_EXTENSION_DIR, PHP_EXTENSION_DIR, PHP_BINDIR, PHP_LIBDIR, PHP_DATADIR, PHP_SYSCONFDIR, PHP_LOCALSTATEDIR, PHP_CONFIG_FILE_PATH].

-urs

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-07 20:15 UTC] ssb@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

Here's the new code.  If you have MSVC installed, please try building and test if you can actually set these PHP constants through environment.

#define CONDENV(ev,def) (getenv(ev)!=NULL?getenv(ev):def)

#define CONFIGURATION_FILE_PATH "php.ini"
#define PEAR_INSTALLDIR          CONDENV("PEAR_INSTALLDIR", "c:\\php4\\pear")
#define PHP_BINDIR               CONDENV("PHP_BINDIR", "c:\\php4")
#define PHP_CONFIG_FILE_PATH     CONDENV("SystemRoot", "")
#define PHP_CONFIG_FILE_SCAN_DIR CONDENV("PHP_CONFIG_FILE_SCAN_DIR", "")
#define PHP_DATADIR              CONDENV("PHP_DATADIR", "c:\\php4")
#define PHP_EXTENSION_DIR        CONDENV("PHP_EXTENSION_DIR", "c:\\php4")
#define PHP_INCLUDE_PATH         CONDENV("PHP_INCLUDE_PATH", ".;c:\\php4\\pear")
#define PHP_LIBDIR               CONDENV("PHP_LIBDIR", "c:\\php4")
#define PHP_LOCALSTATEDIR        CONDENV("PHP_LOCALSTATEDIR", "c:\\php4")
#define PHP_PREFIX               CONDENV("PHP_PREFIX", "c:\\php4")
#define PHP_SYSCONFDIR           CONDENV("PHP_SYSCONFDIR", "c:\\php4")


 [2003-03-24 15:59 UTC] stone@php.net
Reopened, should maybe be marked as critical:

Setting the environment variables has no effect or strange effects) on PHP constants on Win32. This might be the main cause for pear installations failing on windows if php is not installed in c:\php4 (and for PEAR BETA status on Win32).

In the following test script
- PHP_BINDIR is set in the environment
- The setting does not get reflected in the PHP constant
- Mistriously it's not read correctly by getenv()

test script (dos shell):
************************
set PHP_BINDIR="my_php_bindir"
set PHP_BINDIR
cli\php -r "echo PHP_BINDIR;"
cli\php -r "echo getenv('PHP_BINDIR');"
 [2003-05-08 12:32 UTC] pajoye@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

Overriding Constants is not solved. But PEAR does not take care of these constants anymore.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 14:01:32 2024 UTC