Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Error/Bug in admin version of tep_not_null-function


AngusD

Recommended Posts

Hello,

 

I've finally updated to OSC 2.3.4 (bootstraped; thanks to all who made this version) and I believe, there's an error/bug in the admin version of the tep_not_null-function. This error/bug was also present in the previous versions of OSC.

 

Here's the function:



  function tep_not_null($value) {
    if (is_array($value)) {
      if (sizeof($value) > 0) {
        return true;
      } else {
        return false;
      }
    } else {
      if ( (is_string($value) || is_int($value)) && ($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) {
        return true;
      } else {
        return false;
      }
    }
  }

The Problem is the "is_int($value)". This should be "is_numeric($value)", or not?

 

I always wondered, why my currencies wouldn't update, so I've let OSC output the rate-variable of the currency-update-action and it was filled, but because the rate was neither string nor int - it's a decimal - the whole tep_not_null-function returned false.

 

The is_numeric-function returns true, if the variable is an integer, but also if the variable is a decimal.

 

I've also noticed, the admin-version of tep_not_null() differs from the frontend-version (the whole is_string, is_int part is missing).

 

AD

Link to comment
Share on other sites

Addendum: Yes, I'm aware I could have modified the "quote_*_currency"-function, so that it returned a string, but I stand by what I wrote.

 

The "tep_not_null"-function is a very nice function and changing "is_int" to "is_numeric" would make the "tep_not_null"-function more flexible.

 

AD

Link to comment
Share on other sites

This can be improved. Please add this to bug reports http://www.oscommerce.com/forums/tracker/project-1-oscommerce-online-merchant-v2x/

 

I've tried to rewrite it as this:

function tep_not_null($value) {
  return (!in_array($value, array(null, false, (int)0, (float)0, '', array(),(object)array()), true));
}

but does not check for objects

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...