View Issue Details

IDProjectCategoryView StatusLast Update
0007746OXID eShop (all versions)4.01. Database handlingpublic2024-11-27 09:45
Reportermichael_keiluweit Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status confirmedResolutionopen 
Product Version7.2.0 
Summary0007746: Fetch mode gets mapped to wrong mode
DescriptionWhen 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
];


TagsNo tags attached.
ThemeNot defined
BrowserNot defined
PHP VersionNot defined
Database VersionNot defined

Activities

There are no notes attached to this issue.