View Issue Details

IDProjectCategoryView StatusLast Update
0006287OXID eShop (all versions)4.01. Database handlingpublic2015-12-15 12:47
Reporterleofonic 
PrioritynormalSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version4.9.6 / 5.2.6 
Target VersionFixed in Version 
Summary0006287: oxarticle::load doesn't reset long description
DescriptionIf an oxarticle object is reused by calling load() with another oxid, an already fetched long description will not be filled with new data.
Steps To Reproduceexecute this in root directory:

<?php
require_once "bootstrap.php";
$oArticle = oxnew('oxarticle');
//load Trapez ION MADTRIXX
$oArticle->load('05848170643ab0deb9914566391c0c63');
//Long description is from Trapez ION MADTRIXX
var_dump($oArticle->getLongDescription());
//load Klebeband DACRON KITEFIX
$oArticle->load('0584e8b766a4de2177f9ed11d1587f55');
//Long description is from Trapez ION MADTRIXX
var_dump($oArticle->getLongDescription());
TagsArticle
ThemeNot defined
BrowserNot defined
PHP VersionNot defined
MySQL VersionNot defined

Activities

michael_keiluweit

2015-12-15 09:14

developer   ~0011375

Reporter is right. After calling the long description by its getter there is no "good" way to put the value back to "null", therefore the getter would have to load it again.


It's needed to consider how it should be handled correctly:

1. The method "load" has to check if the object was already loaded. This can be done by checking the given parameter oxid if it is different to the stored oxid in the article object. If they aren't equal, the object must be reset like as oxNew('oxarticle') would do.
2. reload / reset function. Makes the same as 1., it's just a clearer way to go and less magic.
3. Define a general rule: Don't use the method load to recycle an object, instantiate an own object instead of use an old one.


A quick hack to force a reload of the long description if the given oxid is different to the last one, is to overwrite the load method and add at the top the following check:
if ($sOXID !== $this->_sOXID) {
    $this->_oLongDesc = null;
}

leofonic

2015-12-15 12:47

reporter   ~0011376

I think you can take away the condition and just use
$this->_oLongDesc = null;
in load() method.

Even if the same oxid is loaded, which would be a rare case anyway, you do not want cached content but content from DB.

"3. Define a general rule: Don't use the method load to recycle an object,"
I would rather define a general rule: method load should reset cached content. Reusing objects makes sense because it uses less memory.