Thomas789 Posted April 24, 2013 Posted April 24, 2013 After upgrading our web server to PHP 5.4, the following code in includes/application_top.php if ( !tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) { if (!tep_session_is_registered('currency')) tep_session_register('currency'); if (isset($HTTP_GET_VARS['currency']) && $currencies->is_set($HTTP_GET_VARS['currency'])) { $currency = $HTTP_GET_VARS['currency']; } else { $currency = ((USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && $currencies->is_set(LANGUAGE_CURRENCY)) ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY; } } leads to the $currency variable being undefined following the first click after entering the site. All the prices therefore show 0 until the currency is changed. This problem did not occur with PHP 5.2 or PHP 5.3. I have patched the code up now as follows if ( !isset($currency) || !tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) { if (!tep_session_is_registered('currency')) tep_session_register('currency'); if (isset($HTTP_GET_VARS['currency']) && $currencies->is_set($HTTP_GET_VARS['currency'])) { $currency = $HTTP_GET_VARS['currency']; } else { $currency = ((USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && $currencies->is_set(LANGUAGE_CURRENCY)) ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY; } } and everything works as it should, but I would still appreciate any insights into this. Thomas
Thomas789 Posted April 24, 2013 Author Posted April 24, 2013 It was originally an OsC 2.2 MS2 cart, but has been upgraded and modified in many ways. All the patches mentioned elsewhere to make it work with PHP 5.4 have been applied. I would also like to mention that USE_DEFAULT_LANGUAGE_CURRENCY == 'false' in this case. I figured out that the problem seems to be that in the function tep_session_is_registered() , array_key_exists() returns true even if the key is NULL in $_SESSION, but according to my tests it does the same in PHP 5.2, so this alone does not explain why the problem with the prices showing zero only occurs in PHP 5.4. Thomas
burt Posted April 24, 2013 Posted April 24, 2013 Try: https://github.com/osCommerce/oscommerce2/commit/9a4d1e6ab9ed87bdc20543995448b114364426b9
Thomas789 Posted April 25, 2013 Author Posted April 25, 2013 Try: https://github.com/osCommerce/oscommerce2/commit/9a4d1e6ab9ed87bdc20543995448b114364426b9 Hi Burt, Yes, thanks, that does the trick as well, as does moving the line if (!tep_session_is_registered('currency')) tep_session_register('currency'); below the initialization of $currency (which would make more sense anyway considering that the latter is referenced in the function tep_session_register). Still, any ideas why this problem does not occur for PHP versions <5.4? I am slightly worried that there may still be related problems lurking somewhere. Thomas
Recommended Posts
Archived
This topic is now archived and is closed to further replies.