News:

Support the VirtueMart project and become a member

Main Menu

crashing bug in models/Orders

Started by whisky, July 29, 2014, 10:32:32 AM

Previous topic - Next topic

whisky

I was debugging a problem with cybermut and the proper way to call one of my plug-in on the payment notification.

In one of the vituemart code, there is a call to models/Orders:updateSingleItem()
in that method around lines 344-346 there is this code :

      $orderdatacopy = $orderdata;
      $data = array_merge($dataT,(array)$orderdatacopy);
//       $data['order_status'] = $orderdata->order status;

The array_merge just crash PHP as the (array) typecast form the order object in $orderdatacopy just do not work !

I changed those lines to :

      $orderdatacopy = get_object_vars($orderdata);
      $data = array_merge($dataT,(array)$orderdatacopy);

and php can go further.

vm is at the last version 2.6.6(.2)
php is 5.4.25


Milbo

#1
Whisky, you ignore that it works for others.

It works very often to just use a cast to make an object to an array. So calm down and learn how a Pro would say it.

"I found out that the array_merge does not work in my case, I use php5.4.25, when I replace the cast against get_object_vars, it works."

Otherwise we just feel that you are one of these guys http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect

btw http://stackoverflow.com/questions/4345554/convert-php-object-to-associative-array

You can find a lot technics how to convert an object in an assoc array. Any technic has some problem
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

GJC Web Design

I propose we make a new board for the Dunning–Kruger posters.. I have loads of my own personally incompetent and badly mis-guided advice that I have given over the years -
I think they deserve a board all of it's own....
happy to moderate it...
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

Milbo

A board with the Topic

"Known critics and the better answer" ?
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

whisky

You can make fun of me as long as you want, it remains that if I read your minimum spec for php version.
My PHP 5.4.25 (that I gave for providing required details as your forum guideline ask) fit the bill.

So when running that code, the cgi (or inside my debugger in PHPStorm) doesn't survive after that line.

You could think whatever you want about it, when I need to spend some time to seek out why
between two calls, virtuemart just die inside and the culprit sound to be that line,
my point is that it stil a bug.

But perhaps, you should state that it is fine on a version of PHP different, that the one I use here
and I'll be glad to test it.

By the way :

Talking about style, someone that write code like :

   $product = (object)array_merge ((array)$product, (array)$product->prices[0]);

could effectively give some lessons to other ;-)

Seen the rest of the code (and spending a LOT of time, making it work properly, your right,
I should admit that your style and mine are not on the same stand, and you won certainly the Kruger award, but more on the Friday 13 Fredy Kruger show ;-)


Milbo

Also this construction is completly different in vm3. So what you do is a lame. VirtueMart is a project and had to deal with different styles of different coders from begin on. Compared to what we got, it is quite the same style now.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/