Upgrade from J2.5.x to J3.4.x causes errors in Virtuemart 3

Started by ntm91307, October 26, 2015, 02:22:08 AM

Previous topic - Next topic

innato

Quote from: GJC Web Design on October 27, 2015, 22:24:51 PM
QuoteNotice: Undefined property: stdClass::$customfield_price
in /home/momsfavoritefudge/public_html/components/com_virtuemart/sublayouts/customfield.php on line 426

Notice: Undefined property: stdClass::$customfield_value
in /home/momsfavoritefudge/public_html/components/com_virtuemart/sublayouts/customfield.php on line 430

Notice: Undefined property: stdClass::$customfield_value
in /home/momsfavoritefudge/public_html/components/com_virtuemart/sublayouts/customfield.php on line 431

these are just notices and won't affect the function of the file .. your error reporting is very high to be showing these

Using VM 3.0.16 on J3.6.2 and PHP 5.6.24.

I stumbled across the above post because I was getting the $customfield_value notice as well. I don't want notices, even if they're told to be 'harmless' (they may not be harmless at all).
In my VM version 3.0.16 the $customfield_price issue appears to have fixed, and the same hack should have been used for $customfield_value

In file /components/com_virtuemart/sublayouts/customfield.php line 457 reads:


         if(!isset($productCustom->customfield_price)) $productCustom->customfield_price = 0.0;


Now add an additional line so that it reads:


         if(!isset($productCustom->customfield_price)) $productCustom->customfield_price = 0.0;
         if(!isset($productCustom->customfield_value)) $productCustom->customfield_value = '';


and you're done in a jiffy!

I am posting this, so that others may benefit and the VM team can include it in the next VM release.
Regards
Rob

VM3.2.6 (enhanced) on J3.8.8 and PHP 7.1 or 7.2

GJC Web Design

please check on VM3.0.17.6 as this is the latest dev version which shortly will be released as VM3.0.18

http://dev.virtuemart.net/attachments/download/1011/com_virtuemart.3.0.17.6_extract_first.zip

many of these small changes may have been done

BTW -- vm extensions is running on 3.0.17.6 so almost production ready

Quoteeven if they're told to be 'harmless' (they may not be harmless at all)

they are harmless otherwise php would 'error' or 'warning' them
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

innato

Quote from: GJC Web Design on August 25, 2016, 15:29:47 PM

Quoteeven if they're told to be 'harmless' (they may not be harmless at all)

they are harmless otherwise php would 'error' or 'warning' them

Agree, but what is harmless for PHP may still not be harmless for the outcome/result of the software if it's not sufficiently robust.

Thanks for the hint ref VM3.0.17, but I'll wait for the first next stable version because it goes into a production site.
Regards
Rob

VM3.2.6 (enhanced) on J3.8.8 and PHP 7.1 or 7.2

Milbo

Quote from: innato on August 25, 2016, 18:24:02 PM
Quote from: GJC Web Design on August 25, 2016, 15:29:47 PM

Quoteeven if they're told to be 'harmless' (they may not be harmless at all)

they are harmless otherwise php would 'error' or 'warning' them

Agree, but what is harmless for PHP may still not be harmless for the outcome/result of the software if it's not sufficiently robust.

Thanks for the hint ref VM3.0.17, but I'll wait for the first next stable version because it goes into a production site.


and how should we know then, if vm3.0.17 has the error?

it just leads to the situation, that you have the error in vm3.0.18, pure logic, we are no wizards.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

innato

Milbo, lucky you that you are 'only' human and not a wizard. Welcome to the club  ;)
Well, if you guys are developing/fine-tuning VM3.0.17, I guess you have installed it somewhere. The error has been described in sufficient detail, so you could see if it occurs on your VM3.0.17 install. There is no magic to that.
The alternative is that I have to upgrade my present VM3.0.16 on my production site (the only place where I use VM), with the risk of seeing the error again and having to reverse the upgrade. I could also setup a test site and install VM3.0.17 there. Both alternatives are significantly more effort than the first.
I was just trying to give you constructive feedback for you to benefit from. I had already applied the hack to my production site.
Regards
Rob

VM3.2.6 (enhanced) on J3.8.8 and PHP 7.1 or 7.2

Milbo

Quote from: innato on September 16, 2016, 13:25:54 PM
Well, if you guys are developing/fine-tuning VM3.0.17, I guess you have installed it somewhere. The error has been described in sufficient detail, so you could see if it occurs on your VM3.0.17 install. There is no magic to that.

I cant reproduce it, you do not even tell whicht customfield type yo use. My more than 10 years experience with programming tells me that if someone finds a bug, always ask him to test the fix himself. Else you test very likely something else. Standard Problem.

Quote from: innato on September 16, 2016, 13:25:54 PM
The alternative is that I have to upgrade my present VM3.0.16 on my production site (the only place where I use VM), with the risk of seeing the error again and having to reverse the upgrade. I could also setup a test site and install VM3.0.17 there. Both alternatives are significantly more effort than the first.

no, setting up a vm with fullinstaller takes 5 minutes. VirtueMart is a project and I wrote the 95% of the code, so it is also a time problem.

Quote from: innato on September 16, 2016, 13:25:54 PM
I was just trying to give you constructive feedback for you to benefit from. I had already applied the hack to my production site.

Which I cannot use, because the files changed a lot. It would have been also enough, just to exchange the file, to check if the error is still in the file
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

innato

Yes the problem still exists in VM3.0.18.
This is the fix:

File /components/com_virtuemart/sublayouts/customfield.php

Change: Line 518 of current file should become line 516 of new file

Present code
=========


513 $default = reset($customfields[$selectList[$customfield->virtuemart_custom_id]]->options);
514 foreach ($customfields[$selectList[$customfield->virtuemart_custom_id]]->options as &$productCustom) {
515 if(!isset($productCustom->customfield_price)) $productCustom->customfield_price = 0.0;
516 $price = VirtueMartModelCustomfields::_getCustomPrice($productCustom->customfield_price, $currency, $calculator);
517 if($type == 'M'){
518 if(!isset($productCustom->customfield_value)) $productCustom->customfield_value = '';
519 $productCustom->text = VirtueMartModelCustomfields::displayCustomMedia ($productCustom->customfield_value,'product',$customfield->width,$customfield->height).' '.$price;
520 } else {
521 $trValue = vmText::_($productCustom->customfield_value);
522 if($productCustom->customfield_value!=$trValue and strpos($trValue,'%1')!==false){
523 $productCustom->text = vmText::sprintf($productCustom->customfield_value,$price);
524 } else {
525 $productCustom->text = $trValue.' '.$price;
526 }
527 }
528 }



Should be
=======


513 $default = reset($customfields[$selectList[$customfield->virtuemart_custom_id]]->options);
514 foreach ($customfields[$selectList[$customfield->virtuemart_custom_id]]->options as &$productCustom) {
515 if(!isset($productCustom->customfield_price)) $productCustom->customfield_price = 0.0;
516 if(!isset($productCustom->customfield_value)) $productCustom->customfield_value = '';
517 $price = VirtueMartModelCustomfields::_getCustomPrice($productCustom->customfield_price, $currency, $calculator);
518 if($type == 'M'){
519 $productCustom->text = VirtueMartModelCustomfields::displayCustomMedia ($productCustom->customfield_value,'product',$customfield->width,$customfield->height).' '.$price;
520 } else {
521 $trValue = vmText::_($productCustom->customfield_value);
522 if($productCustom->customfield_value!=$trValue and strpos($trValue,'%1')!==false){
523 $productCustom->text = vmText::sprintf($productCustom->customfield_value,$price);
524 } else {
525 $productCustom->text = $trValue.' '.$price;
526 }
527 }
528 }


Regards
Rob

VM3.2.6 (enhanced) on J3.8.8 and PHP 7.1 or 7.2

Milbo

Sadly not in the new release. So it is just setting the default value for any type and not just type = M, okey.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

innato

Regards
Rob

VM3.2.6 (enhanced) on J3.8.8 and PHP 7.1 or 7.2