Author Topic: virtuemart 3rd plugin and extension PHP 7 compatibility  (Read 216 times)

istvixs

  • Beginner
  • *
  • Posts: 9
virtuemart 3rd plugin and extension PHP 7 compatibility
« on: June 20, 2017, 11:42:36 am »
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

Code: [Select]
$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

  • Jr. Member
  • **
  • Posts: 320
Re: virtuemart 3rd plugin and extension PHP 7 compatibility
« Reply #1 on: June 20, 2017, 12:35:17 pm »
What error are you getting?

istvixs

  • Beginner
  • *
  • Posts: 9
Re: virtuemart 3rd plugin and extension PHP 7 compatibility
« Reply #2 on: June 20, 2017, 13:04:55 pm »
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

  • Jr. Member
  • **
  • Posts: 320
Re: virtuemart 3rd plugin and extension PHP 7 compatibility
« Reply #3 on: June 20, 2017, 13:11:20 pm »
Can you post var_dump of $values?

istvixs

  • Beginner
  • *
  • Posts: 9
Re: virtuemart 3rd plugin and extension PHP 7 compatibility
« Reply #4 on: June 20, 2017, 13:56:16 pm »
Attached picture php 5.x and php 7.x

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9085
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: virtuemart 3rd plugin and extension PHP 7 compatibility
« Reply #5 on: June 20, 2017, 15:01:13 pm »
Code: [Select]
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
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

istvixs

  • Beginner
  • *
  • Posts: 9
Re: virtuemart 3rd plugin and extension PHP 7 compatibility
« Reply #6 on: June 20, 2017, 15:07:02 pm »
Thanks Boys,

var_dump($value) php5:
Code: [Select]
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