Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Zend_Db_Table_Abstract::find not working with empty values in primary keys #18

Open
GustavR opened this issue Nov 26, 2018 · 0 comments

Comments

@GustavR
Copy link

GustavR commented Nov 26, 2018

Zend_Db_Table_Abstract::find
lines 1307 to 1322

/**
 * PHP 7.2 PATCH -->
 */
if (is_array($keyValues) || $keyValues instanceof \Countable) {
    $keyValuesCount = count($keyValues);
} else {
    if (null == $keyValues) {
        $keyValuesCount = 0;
    } else {
        $keyValuesCount = 1;
    }
}
#$keyValuesCount = count($keyValues);
/**
 * PHP 7.2 PATCH <--
 */

should be

/**
 * PHP 7.2 PATCH -->
 */
if (is_array($keyValues) || $keyValues instanceof \Countable) {
    $keyValuesCount = count($keyValues);
} else {
    if (null === $keyValues) {
        $keyValuesCount = 0;
    } else {
        $keyValuesCount = 1;
    }
}
#$keyValuesCount = count($keyValues);
/**
 * PHP 7.2 PATCH <--
 */

Mind the null == vs null ===
Else when you insert "" as a value into a primary key an Exception will be thrown.
In PHP 5.6 count("") is 1 not 0, but null == "", so that doesnt add up.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant