Topic: Bug in includes\ui\ui_input.inc

Hi,

With debugging on I notice a lot of these messages occuring through out the application, for example:

A non-numeric value encountered in file: C:\Users\Paul\htdocs\fa24\includes\ui\ui_input.inc at line 350
C:\Users\Paul\htdocs\fa24\sales\manage\customers.php:330:     check_value('show_inactive')

Problem is in function check_vaule

function check_value($name)
{
    if (!isset($_POST[$name]) || ($_POST[$name]+0) === 0)
        return 0;
    return 1;
}

And is related to GIT dc449868579dadd4fb918b6a9a7b10ba175d388b

-    if (!isset($_POST[$name]) || $_POST[$name]=='')
+    if (!isset($_POST[$name]) || ($_POST[$name]+0) === 0)

There seems to be three values passed to this function: NULL, '', '1'. The error is occurring when the check box is not ticked (ie: '')

I propose this as a possible solution:

function check_value($name)
{
    if (!isset($_POST[$name]))
        return 0;
    if ($_POST[$name] === 0)
        return 0;
    return 1;
}

Hope this helps.

Re: Bug in includes\ui\ui_input.inc

The bug you are reporting is throwing on PHP7 and 7.1.  If you want to solve the bug go with is_numeric function to check the given value is number or non number.

error_reporting(E_ALL & ~(E_STRICT|E_NOTICE));

to ommit this error by using this one.

Subscription service based on FA
HRM CRM POS batch Themes

Re: Bug in includes\ui\ui_input.inc

Hi @kvvaradha,

Yes, it is with PHP 7.1.

I have confirmed that is_numeric is a solution.

function check_value($name)
{
    if (!isset($_POST[$name]) || !is_numeric($_POST[$name]))
        return 0;
    return 1;
}

I need to leave the debugging on while I work on my own code.

Thanks.

Re: Bug in includes\ui\ui_input.inc

@joe: If this works on older PHP versions, it can make it to the core.

Re: Bug in includes\ui\ui_input.inc

I will try to fix this.

Joe

Re: Bug in includes\ui\ui_input.inc

Hello again,

As far as I understand the POST values from a checkbox is not set if it is not marked. So why not do this?

function check_value($name)
{
    return (empty($_POST[$name]) ? 0 : 1);
}

Joe

Re: Bug in includes\ui\ui_input.inc

This change has been committed now. Repo updated.

/Joe