View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0007746 | OXID eShop (all versions) | 4.01. Database handling | public | 2024-11-19 11:35 | 2024-11-27 09:45 |
Reporter | michael_keiluweit | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | confirmed | Resolution | open | ||
Product Version | 7.2.0 | ||||
Summary | 0007746: Fetch mode gets mapped to wrong mode | ||||
Description | When calling the method \OxidEsales\Eshop\Core\Base::loadVarsFromDb the fetch mode will be set to 3, which later is mapped to PDO::FETCH_BOTH instead of PDO::FETCH_ASSOC. \OxidEsales\Eshop\Core\Base::loadVarsFromDb is the very first method to call the database wrapper and does not define the fetch mode. So the default will be set to 1 (DatabaseProvider::FETCH_MODE_NUM (1). This variable is injected into \OxidEsales\EshopCommunity\Core\Database\Adapter\Doctrine::setFetchMode. The object maps the value 1 to PDO::FETCH_BOTH. At this moment we lost the explicit ASSOC mode and the result is maybe a numeric array or an associative array. | ||||
Steps To Reproduce | $p = oxNew(Article::class); $p->onChange(Article::DEPENDENCY_EVENT_STOCK_CHANGED, 'random_parent_id'); The method Article::onChange does call the method Article::setVarMinMaxPrice which depends on an ASSOC result. But it gets the first result as numeric, when it runs through its loop. This leads to a wrong value for oxarticle.oxvarminprice and oxarticle.oxvarmaxprice in the database for the first object in the list. After the first iteration, the fetch mode is set correctly to ASSOC again, and the results are fine | ||||
Additional Information | OxidEsales\EshopCommunity\Core\Database\Adapter\DatabaseInterface::FETCH_MODE_NUM = 1 OxidEsales\EshopCommunity\Core\Database\Adapter\DatabaseInterface::FETCH_MODE_ASSOC = 2 OxidEsales\EshopCommunity\Core\Database\Adapter\DatabaseInterface::FETCH_MODE_BOTH = 3 OxidEsales\EshopCommunity\Core\Database\Adapter\Doctrine\Database: protected $fetchModeMap = [ DatabaseInterface::FETCH_MODE_DEFAULT => PDO::FETCH_BOTH, DatabaseInterface::FETCH_MODE_NUM => PDO::FETCH_NUM, DatabaseInterface::FETCH_MODE_ASSOC => PDO::FETCH_ASSOC, DatabaseInterface::FETCH_MODE_BOTH => PDO::FETCH_BOTH ]; | ||||
Tags | No tags attached. | ||||
Theme | Not defined | ||||
Browser | Not defined | ||||
PHP Version | Not defined | ||||
Database Version | Not defined | ||||