virtuemart 3rd plugin and extension PHP 7 compatibility

Started by istvixs, June 20, 2017, 11:42:36 AM

Previous topic - Next topic

istvixs

Hi, my favorite plugin multiple customfields filter for virtuemart, is not fully compatible with php 7. Unfortunately no support, and I need a quick solution. php 7 incompatible code the following:
/plugins/vmcustom/param/param/tmpl/default.php


$values = $viewData->value;
if(count($values) > 0){
$html .='<div class="product-fields-value">';
$html .= '<ul>';
foreach($values as &$v){
if($viewData->ft == 'int'){
$html .= '<li>'.$v->intval.'</li>';
}else{
$html .= '<li>'.JText::_($v->value).'</li>';
}
}unset($v);
$html .= '</ul>';
$html .='</div></div>';
echo $html;
}

int problem, JText works.
Thank you in advance for your help!

Ghost


istvixs

I think foreach cycle php5 and 7 different problem, see attached picture. ROM and OS text values, battery integer values. Integer values empty, no value. Text is ok.

Ghost


istvixs


Milbo


foreach($values as &$v){
if($viewData->ft == 'int'){
$html .= '<li>'.$v->intval.'</li>';
}else{
$html .= '<li>'.JText::_($v->value).'</li>';
}
}
unset($v);



That is shit here. The $v, you unset it outside of the foreach. And it is not wise to use a link/point in the foreach. Better use foreach($values as $k=>$v) and manipulate the elements with $value[$k] instead of the &$v
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

istvixs

Thanks Boys,

var_dump($value) php5:
array(1) { [0]=> &object(stdClass)#1229 (9) { ["id"]=> NULL ["virtuemart_product_id"]=> string(3) "489" ["virtuemart_custom_id"]=> NULL ["val"]=> string(1) "0" ["intval"]=> string(4) "4100" ["value"]=> NULL ["status"]=> NULL ["published"]=> NULL ["ordering"]=> NULL } }

var_dump($value) php7: nothing