From: SourceForge.net <no...@so...> - 2009-11-18 21:16:56
|
Bugs item #2897990, was opened at 2009-11-15 13:34 Message generated for change (Comment added) made by liedekef You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=108956&aid=2897990&group_id=8956 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: User Group: 2.1.3 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Arjen van Bochoven (bochoven) Assigned to: Nobody/Anonymous (nobody) Summary: uninitialized GLOBALS array breaks esp_setlocale() Initial Comment: On line 94 of php.ini.fixed, a call is made to esp_setlocale_ex() which in turn calls esp_setlocale() (both live in espi18n.inc). On line 110, 114 and 115 of espi18n.inc, esp_setlocale() accesses $ESPCONFIG as a global variable, which is not initialized yet. Initialization of $GLOBALS['ESPCONFIG'] happens at the end of php.ini.fixed, so after the part that references esp_setlocale(); As a quick fix I moved the initialization part above the esp_setlocale() calls. As a consequence, all references to the ESPCONFIG array that come after that have to be changed to $GLOBALS['ESPCONFIG'] here's my changed code for php.ini.fixed starting on line 91 till the end of the file: if (isset($GLOBALS)) { $GLOBALS['ESPCONFIG'] = $ESPCONFIG; } else { global $ESPCONFIG; } // Load I18N support require_once($GLOBALS['ESPCONFIG']['include_path'] . '/lib/espi18n' . $GLOBALS['ESPCONFIG']['extension']); if (isset($_REQUEST['lang'])) { esp_setlocale_ex($_REQUEST['lang']); $_SESSION['language']=$_REQUEST['lang']; } elseif (isset($lang)) { esp_setlocale_ex($lang); $_SESSION['language']=$lang; } elseif (isset($_SESSION['language'])) { esp_setlocale_ex($_SESSION['language']); } else { esp_setlocale_ex(); } // default thank you messages $GLOBALS['ESPCONFIG']['thank_head'] = _('Thank You For Completing This Survey.'); $GLOBALS['ESPCONFIG']['thank_body'] = _('Please do not use the back button on your browser to go back.'); if (!file_exists($GLOBALS['ESPCONFIG']['include_path']. '/funcs'. $GLOBALS['ESPCONFIG']['extension'])) { printf('<b>'. _('Unable to find the phpESP %s directory. Please check %s to ensure that all paths are set correctly.') . '</b>', 'include', 'phpESP.ini.php'); exit; } if (!file_exists($GLOBALS['ESPCONFIG']['css_path'])) { printf('<b>'. _('Unable to find the phpESP %s directory. Please check %s to ensure that all paths are set correctly.') . '</b>', 'css', 'phpESP.ini.php'); exit; } require_once($GLOBALS['ESPCONFIG']['include_path'].'/funcs'.$GLOBALS['ESPCONFIG']['extension']); ?> ---------------------------------------------------------------------- >Comment By: Franky Van Liedekerke (liedekef) Date: 2009-11-18 22:16 Message: I found this one weird, so I took a deeper look at it. First of all: I don't like the use of global variables, but that put aside, I believe this remark to be wrong: in php, using "global <variablename>", refers to the value of the variable outside the function, see http://php.net/manual/en/language.variables.scope.php (example 2). Using $GLOBALS should be removed as much as possible, but I didn't get around to doing that (yet), but still it doesn't change the fact that it remains the same. What did you see as an error when you claim that "uninitialized GLOBALS array breaks esp_setlocale()"? ---------------------------------------------------------------------- Comment By: Arjen van Bochoven (bochoven) Date: 2009-11-15 20:28 Message: Hmm, further investigation showed that this problem only arises when you don't include the handler.php in global space (eg in a function or a class). I would still want to flag this as a bug. Example code below: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>survey</title> </head> <body> <?php ini_set( 'display_errors', true ); error_reporting(E_ALL); function survey() { $lang='nl_NL'; $sid=9; include("/home/bochoven/php/phpESP/public/phpESP.first.php"); include("/home/bochoven/php/phpESP/public/handler.php"); } survey(); ?> </body> </html> ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=108956&aid=2897990&group_id=8956 |