VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: whisky on July 29, 2014, 10:32:32 AM

Title: crashing bug in models/Orders
Post by: whisky on July 29, 2014, 10:32:32 AM
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

Title: Re: crashing bug in models/Orders
Post by: Milbo on July 29, 2014, 11:32:51 AM
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
Title: Re: crashing bug in models/Orders
Post by: GJC Web Design on July 29, 2014, 12:55:54 PM
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...
Title: Re: crashing bug in models/Orders
Post by: Milbo on July 29, 2014, 14:26:16 PM
A board with the Topic

"Known critics and the better answer" ?
Title: Re: crashing bug in models/Orders
Post by: whisky on July 29, 2014, 20:44:45 PM
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 ;-)

Title: Re: crashing bug in models/Orders
Post by: Milbo on July 30, 2014, 01:42:08 AM
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.