lat9 / options_stock_support

Products' Options' Stock Manager: Support Thread
0 stars 3 forks source link

disabled checkbox true/false type #28

Closed torvista closed 4 years ago

torvista commented 4 years ago

While fighting with something else and using your code as reference, I see this:

if (isset($_GET['disabled'])) {
    $include_disabled = ($_GET['disabled'] === 'true');
} elseif (isset($_SESSION['posm_include_disabled'])) {
    $include_disabled = $_SESSION['posm_include_disabled'];
} else {
    $include_disabled = (POSM_INCLUDE_DISABLED_DEFAULT === 'true');
}
$_SESSION['posm_include_disabled'] = $include_disabled;

As far as I can find out, SESSION variables are always strings, so the first clause would set $include_disabled as true (boolean), the second clause would set $include_disabled as 'true' (string), the third clause would set $include_disabled as true (boolean).

Should not the second clause be of a similar structure as the other two?

lat9 commented 4 years ago

$_SESSION variables can be any type required and the $_SESSION['posm_include_disabled'] is always set to a binary value, so that second clause will set $include_disabled to the current boolean value for that session variable.

torvista commented 4 years ago

Ok, I get it thanks.