Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:24426 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39052 invoked by uid 1010); 17 Jul 2006 11:27:40 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 39036 invoked from network); 17 Jul 2006 11:27:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jul 2006 11:27:40 -0000 X-PHP-List-Original-Sender: edink@emini.dk X-Host-Fingerprint: 192.38.9.232 gw2.emini.dk Linux 2.4/2.6 Received: from ([192.38.9.232:8785] helo=gw2.emini.dk) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id AE/71-11992-9247BB44 for ; Mon, 17 Jul 2006 07:27:39 -0400 Received: from [10.0.0.18] (palestine.intra.emini.dk [10.0.0.18]) by gw2.emini.dk (Postfix) with ESMTP id A9F16BB528; Mon, 17 Jul 2006 13:27:34 +0200 (CEST) Message-ID: <44BB7426.9060501@emini.dk> Date: Mon, 17 Jul 2006 12:27:34 +0100 Organization: Emini A/S User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: RQuadling@GoogleMail.com Cc: internals@lists.php.net References: <10845a340607151310od745e13gcd2f9c6137ebb68@mail.gmail.com> <10845a340607160209h427741cevbcf20df09c9501d5@mail.gmail.com> <10845a340607160217n769809agcfa097364d6aee86@mail.gmail.com> <10845a340607170316j7e3440ddlbe62ab8b0a807919@mail.gmail.com> In-Reply-To: <10845a340607170316j7e3440ddlbe62ab8b0a807919@mail.gmail.com> X-Enigmail-Version: 0.94.0.0 OpenPGP: id=157D0FA8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Supporting version specific INI files as well as SAPI specific INI files. From: edink@emini.dk (Edin Kadribasic) Hi Richard, I think your ini changes should be put into PHP. I have a small feature request. Since we're modifying the way ini files are picked up we might as well add support for minor version numbers since PHP is not binary compatible between minor version releases. That would allow people to run 5.0 5.1 and 5.2 in the same system. Edin Richard Quadling wrote: > Having used regmon, in conjunction with the source (still learning my > way around the source), PHP accesses the following registry keys : > > HKLM\SOFTWARE\PHP\IniFilePath > HKLM\SOFTWARE\PHP\Per Directory Values > > > What naming convention would you expect to be used for version > specific settings. I would think a new subkey ... > > (Original) > HKLM\SOFTWARE\PHP\IniFilePath > HKLM\SOFTWARE\PHP\Per Directory Values > > (Additional) > HKLM\SOFTWARE\PHP\V4\IniFilePath > HKLM\SOFTWARE\PHP\V4\Per Directory Values > > HKLM\SOFTWARE\PHP\V5\IniFilePath > HKLM\SOFTWARE\PHP\V5\Per Directory Values > > HKLM\SOFTWARE\PHP\V6\IniFilePath > HKLM\SOFTWARE\PHP\V6\Per Directory Values > > etc. > > The version specific IniFilePath will be added to the search path > BEFORE the default IniFilePath. > > The version specific PerDirectoryValues (if present) would override > the default values (if present). > > > > This is a pretty advanced set of rules for configuring ini settings! > > You can set them globally (either in a INI file or the registry), > based upon the major version of PHP (INI file or registry), where the > PHP file is (registry) and for the specific PHP file (registry), as > well as things like Apache .htaccess or even within the PHP code > itself. > > > If this is all OK, I'll talk to Nuno about incorporating the changes > to the documentation. > > And then, I may leave you all alone! (Well, WIBNI!). > > > > > On 16/07/06, Richard Quadling wrote: >> From my initial look, it seems that the registry only contains the a >> path to the ini file, not the actual ini file itself. >> >> If that is the case, then the patch still stands. >> >> Unless, specific settings can be made to the registry... which makes >> more sense. >> >> So. More looking. >> >> On 16/07/06, Richard Quadling wrote: >> > Even with the FastCGI, you still need to differentiate the versions. >> > It wouldn't matter what SAPI was used. The same SAPI cannot be used >> > for more than 1 version of PHP. >> > >> > I'll take a look at the registry options... >> > >> > Thanks for looking in everyone. >> > >> > Richard. >> > >> ----- >> Richard Quadling >> Zend Certified Engineer : >> http://zend.com/zce.php?c=ZEND002498&r=213474731 >> > > > ------------------------------------------------------------------------ > > Index: main/php_ini.c > =================================================================== > RCS file: /repository/php-src/main/php_ini.c,v > retrieving revision 1.143 > diff -u -r1.143 php_ini.c > --- main/php_ini.c 4 Jul 2006 06:38:32 -0000 1.143 > +++ main/php_ini.c 17 Jul 2006 10:05:50 -0000 > @@ -318,7 +318,17 @@ > > #ifdef PHP_WIN32 > /* Add registry location */ > - reg_location = GetIniPathFromRegistry(); > + /* RAQ : Add version specific registry location */ > + reg_location = GetIniPathFromRegistry(1); > + if (reg_location != NULL) { > + if (*php_ini_search_path) { > + strcat(php_ini_search_path, paths_separator); > + } > + strcat(php_ini_search_path, reg_location); > + efree(reg_location); > + } > + /* RAQ : Get non-version specific registry location : reg_location = GetIniPathFromRegistry(); */ > + reg_location = GetIniPathFromRegistry(0); > if (reg_location != NULL) { > if (*php_ini_search_path) { > strcat(php_ini_search_path, paths_separator); > @@ -428,6 +438,17 @@ > } > } > } > + /* RAQ : Search php%php-major-version%-%sapi-module-name%.ini file in search path */ > + if (!fh.handle.fp) { > + const char *fmt = "php%d-%s.ini"; > + char *ini_fname = emalloc(strlen(fmt) + strlen(sapi_module.name) + (PHP_MAJOR_VERSION < 10 ? 1 : 2)); > + sprintf(ini_fname, fmt, PHP_MAJOR_VERSION, sapi_module.name); > + fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC); > + efree(ini_fname); > + if (fh.handle.fp) { > + fh.filename = php_ini_opened_path; > + } > + } > /* Search php-%sapi-module-name%.ini file in search path */ > if (!fh.handle.fp) { > const char *fmt = "php-%s.ini"; > Index: win32/php_registry.h > =================================================================== > RCS file: /repository/php-src/win32/php_registry.h,v > retrieving revision 1.4 > diff -u -r1.4 php_registry.h > --- win32/php_registry.h 19 Oct 2003 10:22:21 -0000 1.4 > +++ win32/php_registry.h 17 Jul 2006 10:05:51 -0000 > @@ -3,6 +3,7 @@ > > > void UpdateIniFromRegistry(char *path TSRMLS_DC); > -char *GetIniPathFromRegistry(); > +/* RAQ : Allow for version specificness */ > +char *GetIniPathFromRegistry(int version_specific); > > #endif /* PHP_REGISTRY_H */ > Index: win32/registry.c > =================================================================== > RCS file: /repository/php-src/win32/registry.c,v > retrieving revision 1.16 > diff -u -r1.16 registry.c > --- win32/registry.c 14 Mar 2005 12:42:05 -0000 1.16 > +++ win32/registry.c 17 Jul 2006 10:05:51 -0000 > @@ -9,7 +9,26 @@ > HKEY MainKey; > char *strtok_buf = NULL; > > - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, PHP_REGISTRY_KEY "\\Per Directory Values", 0, KEY_READ, &MainKey)!=ERROR_SUCCESS) { > + /* RAQ : Version specificness */ > + int version_specific; > + char * reg_key; > + > + /* RAQ : Get default and then version specific entries. */ > + for (version_specific = 0 ; version_specific < 2 ; ++version_specific) { > + > + /* RAQ : Build key which may include version specificness */ > + DWORD keylen = strlen(PHP_REGISTRY_KEY); > + if (1 == version_specific) { > + reg_key = (char *) emalloc(strlen(PHP_REGISTRY_KEY) + strlen("\\V\\Per Directory Values") + (PHP_MAJOR_VERSION < 10 ? 1 : 2)); > + sprintf(reg_key, "%c\\V%d\\Per Directory Values", PHP_REGISTRY_KEY, PHP_MAJOR_VERSION); > + } else { > + reg_key = (char *) emalloc(strlen(PHP_REGISTRY_KEY) + strlen("\\Per Directory Values")); > + sprintf(reg_key, "%c\\Per Directory Values", PHP_REGISTRY_KEY); > + } > + /* RAQ END : Continue with appropriate key. */ > + > + /* RAQ : Use potentially version specific registry key : if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, PHP_REGISTRY_KEY "\\Per Directory Values", 0, KEY_READ, &MainKey)!=ERROR_SUCCESS) { */ > + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg_key, 0, KEY_READ, &MainKey)!=ERROR_SUCCESS) { > return; > } > > @@ -55,7 +74,7 @@ > HKEY hKey; > DWORD lType; > DWORD values = 0, max_name = 0, max_value = 0, i = 0; > - > + > if (p>path) { > *(p-1) = '\\'; /* restore the slash */ > } > @@ -91,16 +110,29 @@ > } > RegCloseKey(MainKey); > efree(orig_path); > + } /* RAQ : End of version specificness loop */ > } > > #define PHPRC_REGISTRY_NAME "IniFilePath" > > -char *GetIniPathFromRegistry() > +char *GetIniPathFromRegistry(int version_specific) > { > char *reg_location = NULL; > HKEY hKey; > - > - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, PHP_REGISTRY_KEY, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { > + char *reg_key = NULL; > + > + /* RAQ : Build key which may include version specificness */ > + DWORD keylen = strlen(PHP_REGISTRY_KEY); > + if (1 == version_specific) { > + reg_key = (char *) emalloc(strlen(PHP_REGISTRY_KEY) + strlen("\\V") + (PHP_MAJOR_VERSION < 10 ? 1 : 2)); > + sprintf(reg_key, "%c\\V%d", PHP_REGISTRY_KEY, PHP_MAJOR_VERSION); > + } else { > + reg_key = (char *) emalloc(strlen(PHP_REGISTRY_KEY)); > + sprintf(reg_key, "%c", PHP_REGISTRY_KEY); > + } > + > + /* RAQ : Use potentially version specific registry key : if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, PHP_REGISTRY_KEY, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {*/ > + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg_key, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { > DWORD buflen = MAXPATHLEN; > reg_location = emalloc(MAXPATHLEN+1); > if(RegQueryValueEx(hKey, PHPRC_REGISTRY_NAME, 0, NULL, reg_location, &buflen) != ERROR_SUCCESS) { >