[xdebug-dev] xdebug xdebug/xdebug.c - fix retrieval of config information to work correctly for startup

From: Shane Caraveo <shane[@]caraveo.com>
Date: Wed, 23 Jun 2004 23:51:29 +0200

Date: Wed Jun 23 23:51:29 CEST 2004
User: Shane Caraveo
Directory: xdebug

Log Message:
[0.5]
- fix retrieval of config information to work correctly for startup
environment and per request

Modified files:
           xdebug/xdebug.c (version: 1.223)

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.222
retrieving revision 1.223
diff -u -r1.222 -r1.223
--- xdebug/xdebug.c:1.222 Thu Jun 17 13:45:04 2004 GMT
+++ xdebug/xdebug.c Wed Jun 23 19:51:29 2004 GMT
@@ -216,26 +216,6 @@
         return SUCCESS;
 }
 
-static PHP_INI_MH(OnUpdateKey)
-{
- XG(ide_key) = NULL;
- if (!new_value || !*new_value) {
- char *ide_key = getenv("DBGP_IDEKEY");
- if (!ide_key || !*ide_key) {
- ide_key = getenv("USER");
- if (!ide_key || !*ide_key) {
- ide_key = getenv("USERNAME");
- }
- }
- if (ide_key && *ide_key) {
- XG(ide_key) = xdstrdup(ide_key);
- }
- } else {
- XG(ide_key) = xdstrdup(new_value);
- }
- return SUCCESS;
-}
-
 PHP_INI_BEGIN()
         /* Debugger settings */
         STD_PHP_INI_BOOLEAN("xdebug.auto_trace", "0", PHP_INI_ALL, OnUpdateBool, auto_trace, zend_xdebug_globals, xdebug_globals)
@@ -291,7 +271,7 @@
         STD_PHP_INI_ENTRY("xdebug.remote_port", "9000", PHP_INI_ALL, OnUpdateLong, remote_port, zend_xdebug_globals, xdebug_globals)
 #endif
         PHP_INI_ENTRY("xdebug.allowed_clients", "", PHP_INI_SYSTEM, OnUpdateAllowedClients)
- STD_PHP_INI_ENTRY("xdebug.idekey", "", PHP_INI_ALL, OnUpdateKey, ide_key, zend_xdebug_globals, xdebug_globals)
+ STD_PHP_INI_ENTRY("xdebug.idekey", "", PHP_INI_ALL, OnUpdateString, ide_key, zend_xdebug_globals, xdebug_globals)
 PHP_INI_END()
 
 static void php_xdebug_init_globals (zend_xdebug_globals *xg TSRMLS_DC)
@@ -328,6 +308,21 @@
 }
 #endif
 
+
+void xdebug_env_key()
+{
+ char *ide_key = getenv("DBGP_IDEKEY");
+ if (!ide_key || !*ide_key) {
+ ide_key = getenv("USER");
+ if (!ide_key || !*ide_key) {
+ ide_key = getenv("USERNAME");
+ }
+ }
+ if (ide_key && *ide_key) {
+ zend_alter_ini_entry("xdebug.idekey", sizeof("xdebug.idekey"), ide_key, strlen(ide_key), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
+ }
+}
+
 void xdebug_env_config()
 {
         char *config = getenv("XDEBUG_CONFIG");
@@ -337,6 +332,7 @@
                 XDEBUG_CONFIG format:
                 XDEBUG_CONFIG=var=val var=val
         */
+ xdebug_env_key();
         if (!config) {
                 return;
         }
@@ -484,7 +480,8 @@
 PHP_RINIT_FUNCTION(xdebug)
 {
         zend_function *orig;
-
+ char *idekey = zend_ini_string("xdebug.idekey", sizeof("xdebug.idekey"), 0);
+
         XG(level) = 0;
         XG(do_trace) = 0;
         XG(do_code_coverage) = 0;
@@ -497,6 +494,10 @@
         XG(error_handler) = NULL;
         XG(prev_memory) = 0;
         XG(function_count) = 0;
+
+ if (idekey && *idekey) {
+ XG(ide_key) = xdstrdup(idekey);
+ }
 
         /* Only enabled extended info when it is not disabled */
         CG(extended_info) = XG(extended_info);
@@ -889,6 +890,7 @@
                 ) {
                         convert_to_string_ex(dummy);
                         magic_cookie = xdstrdup(Z_STRVAL_PP(dummy));
+ if (XG(ide_key)) xdfree(XG(ide_key));
                         XG(ide_key) = xdstrdup(Z_STRVAL_PP(dummy));
                         php_setcookie("XDEBUG_SESSION", sizeof("XDEBUG_SESSION"), Z_STRVAL_PP(dummy), Z_STRLEN_PP(dummy), time(NULL) + 3600, "/", 1, NULL, 0, 0 COOKIE_ENCODE TSRMLS_CC);
                 } else if (
@@ -897,6 +899,7 @@
                 ) {
                         convert_to_string_ex(dummy);
                         magic_cookie = xdstrdup(Z_STRVAL_PP(dummy));
+ if (XG(ide_key)) xdfree(XG(ide_key));
                         XG(ide_key) = xdstrdup(Z_STRVAL_PP(dummy));
                 } else if (getenv("XDEBUG_CONFIG")) {
                         magic_cookie = xdstrdup(getenv("XDEBUG_CONFIG"));
Received on Wed Jun 23 2004 - 23:51:30 BST

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:02 BST