VirtueMart Forum

VirtueMart 2 + 3 => Virtuemart Development and bug reports => Topic started by: zanardi on March 21, 2014, 11:07:43 am

Title: Content plugin broken in product_desc
Post by: zanardi on March 21, 2014, 11:07:43 am
Using VirtueMart 2.0.26d. I think content plugin processing is broken for product_desc on product_details view.

Here's the code from frontend/views/productdetails/view.html.php (lines 125-127)

Code: [Select]
if (VmConfig::get('enable_content_plugin', 0)) {
shopFunctionsF::triggerContentPlugin($product, 'productdetails','product_desc');
}

And here's the code from frontend/helpers/shopfunctionsf.pgp (lines 698-725)

Code: [Select]
static function triggerContentPlugin(  $article, $context, $field) {
// add content plugin //
$dispatcher =   JDispatcher::getInstance ();
JPluginHelper::importPlugin ('content');
$article->text = $article->$field;
jimport ('joomla.html.parameter');
$params = new JParameter('');

if (JVM_VERSION === 2) {
if (!isset($article->event)) {
$article->event = new stdClass();
}
$results = $dispatcher->trigger ('onContentPrepare', array('com_virtuemart.'.$context, &$article, &$params, 0));
// More events for 3rd party content plugins
// This do not disturb actual plugins, because we don't modify $vendor->text
$res = $dispatcher->trigger ('onContentAfterTitle', array('com_virtuemart.'.$context, &$article, &$params, 0));
$article->event->afterDisplayTitle = trim (implode ("\n", $res));

$res = $dispatcher->trigger ('onContentBeforeDisplay', array('com_virtuemart.'.$context, &$article, &$params, 0));
$article->event->beforeDisplayContent = trim (implode ("\n", $res));

$res = $dispatcher->trigger ('onContentAfterDisplay', array('com_virtuemart.'.$context, &$article, &$params, 0));
$article->event->afterDisplayContent = trim (implode ("\n", $res));
} else {
$results = $dispatcher->trigger ('onPrepareContent', array(& $article, & $params, 0));
}
$article->$field = $article->text;
}

You can see for yourself that $article is not passed as a reference nor it's returned, so of course it will never get modified.

Solution is to alter the signature of the method like this:

Code: [Select]
static function triggerContentPlugin( &$article, $context, $field) {

Hope this helps.
Title: Re: Content plugin broken in product_desc
Post by: Milbo on March 29, 2014, 10:08:10 am
Thank you very much zanardi. I really wonder how this code could work before. But we also have threads in which the content plugin were blocking the pdf creation. Anyway added this way in vm2.5.5, please test.