opensourcepos / opensourcepos

Open Source Point of Sale is a web based point of sale application written in PHP using CodeIgniter framework. It uses MySQL as the data back end and has a Bootstrap 3 based user interface.
http://www.opensourcepos.org
Other
3.48k stars 2.19k forks source link

check_numeric function in Secure_Controller doesn't work correctly in php 7 #2348

Closed bullmike closed 5 years ago

bullmike commented 5 years ago

Check_Numeric function called from Item and Tax config doesn't function correctly in php7.

check_numeric("test") returns 'true'

    public function check_numeric()
    {
            $result = TRUE;
            foreach($this->input->get() as $str)
            {
                    $result &= parse_decimals($str);
            }

            echo $result !== FALSE ? 'true' : 'false';
    }

Not sure why this function is doing a bitwise AND assignment.. '&=' .

Background information

IMPORTANT: If you choose to ignore this issue report template, your issue will be closed as we cannot help without the requested information.

Please make sure you tick (add an x between the square brackets with no spaces) the following check boxes:

Installation information

Issue / Bug / Question / New Feature

Please write your issue here. If a bug, please make sure to provide as much information as possible including configuration settings (e.g. Decimals set, Tax mode), language and steps to reproduce the bug.

jekkos commented 5 years ago

Looks like something we could easily add a unit test for

bullmike commented 5 years ago

perhaps this should use the is_numeric() function ?

jekkos commented 5 years ago

well no not completely. Not sure how it would behave if we then try to parse some numbers formatted in a specific locale.

jekkos commented 5 years ago

Can you specify exactly where this function is not working? Was just trying it with PHP7 and it seems to behave as expected.

jekkos commented 5 years ago

Seems that the behavior of the intl formatter has changed then. Previously it would return FALSE if you would pass it a string that it can't parse. Now it seems to return 0.

daN4cat commented 5 years ago

@odiea, have you ever experienced this with the latest version?

If it's not an issue with 3.3.0 I would close.

odiea commented 5 years ago

All appears to be working correctly for me. If there is a certain test that would be needed I would like to know what it is.

daN4cat commented 5 years ago

I close.