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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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&amp;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) {
>   

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to