You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

VmTable::load possible anomaly if returning data from cache

Started by epsoft, January 26, 2015, 09:40:46 AM

Previous topic - Next topic


The VmTable::load function uses Joomla JTable::bind to return cached data
(in latest trunk  Row:995)

$this->_lhash = md5($oid. $select . $k . $mainTable . $andWhere . $hashVarsToPush);
if (isset (self::$_cache['l'][$this->_lhash])) {

But this function bind only declared property of the object, as stated in the banner

* Method to bind an associative array or object to the JTable instance.This
* method only binds properties that are publicly accessible and optionally
* takes an array of properties to ignore when binding.

and lookin into code

// Bind the source value, excluding the ignored fields.
foreach ($this->getProperties() as $k => $v)
// Only process fields not in the ignore array.
if (!in_array($k, $ignore))
if (isset($src[$k]))
$this->$k = $src[$k];

If a source/cached property/value does not exist in destination object, it won't be returned by the destination object,  without warning or logging

As result, dynamic property and value of the object was not returned if the object is taken from the cache, while it was retured if the object is loaded from database

One example of this behavior will happen on old VM 2.6.14 where product having customfilelds:
the call to VirtueMartModelProduct::getProductSingle return a TableProducts with missing property/value/array if the object is get from cache,
because in the inside function code the $product->load get a cached partial response, and later it test the missing dynamic property $product->virtuemart_customfield_id to determine if need to call getProductCustomsField, so it does not return the expected complete product.

I know that this is a mix issue between VM a Joomla core, where the core has good reason to return clean well-formed object, while VM has no chance to notice the possible anomaly in chached object returned from the core.

I wrote this memo just to warn all programmers / developers on this behavior, maybe it can help someone in need ...


Please check this behaviour in vm3, it should be completly fixed there.
Should I fix your bug, please support the VirtueMart project and become a member
Extensions approved by the core team: