Error with PHP 7: Cannot access property started with '\0'

Started by Romy_Magick, March 23, 2016, 17:53:16 PM

Previous topic - Next topic

Romy_Magick

Hi there!

I tried PHP 7 with J 3.5 and VM 3.0.14, but VM doesn't operate fully functional then.
As I tested the payment process with Amazon payment plugin, the last site (.../mein-warenkorb/confirm) is a 404 with additional Info "Cannot access property started with '\0'".

The very same error showed up when I tried to set the not completed orders to "cancelled" in the order overview from VM. I had 6 orders which weren't processed completly. Of course I wanted to ser them cancelled in a bulk, but only one order status were changed after the error occured and I went back to the order overview. 

After switching back to PHP 5.6, no error occured. I don't know where to start to search. If you need any further information, please let me know.

amlil71

Hello, i try to use php 7 yesterday and i have the same errors with paiement process. I have the same error 404 page with the message "cannot access property start with /0" . Thank you. Regards.

ThiloS

Same here!

Finished process, (with offline Payment) - then i can't reach the bills in the backend.
"Cannot access property started with '\0'".

Jumbo!

Yes, it looks like a bug. Here is a quick solution to the problem.

Open administrator/components/com_virtuemart/models/orders.php

Find the following codes between lines 286 to 291:

$pvar = get_object_vars($product);
foreach ( $pvar as $k => $v) {
if (!isset($item->$k) and '_' != substr($k, 0, 1)) {
$item->$k = $v;
}
}


Replace above by:

$pvar = get_object_vars($product);
foreach ( $pvar as $k => $v) {
if (!isset($item->$k) and '_' != substr($k, 0, 1)) {
$k = trim($k); // Just added this line.
$item->$k = $v;
}
}


Save the file.


ThiloS

jep. everything fine now with that extra line...

Thanks!

amlil71

Hello Jumbo,

thank you very much. It works very well now :)

Milbo

would be interesting to have a vmtrace there to see which object creates the 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/

zbig

I had the same problem and your advices were yery helpful. I changed the file orders.php and it's going fine.
When I used the old file orders.php the error appeared. This is my log in the moment of error:

[Tue Mar 29 18:20:14 2016] [error] [client 00.000.0.00] PHP Warning:  Parameter 1 to plgSystemRsseo::handleError() expected to be a reference, value given in Unknown on line 0, referer: https://kredos.pl/sklep/cart
[Tue Mar 29 18:20:14 2016] [error] [client 00.000.0.00] PHP Fatal error:  Uncaught Error: Cannot access property started with '\\0' in /home/users/serwer/public_html/serwer_kredos/administrator/components/com_virtuemart/models/orders.php:289\nStack trace:\n#0 /home/users/serwer/public_html/serwer_kredos/administrator/components/com_virtuemart/models/orders.php(169): VirtueMartModelOrders->getOrder(247, false)\n#1 /home/users/serwer/public_html/serwer_kredos/components/com_virtuemart/helpers/cart.php(1167): VirtueMartModelOrders->getMyOrderDetails(247, '19250249', 'p_E7J4FTPP')\n#2

This may be helpful.
Best regard. zbig

prokops

The code suggestion took care of my issue, the only remaining thing is this warning on the order page:

QuoteWarning
500

Is this something experienced by others ?



Jumbo!

Quote from: prokops on March 30, 2016, 13:12:48 PM
the only remaining thing is this warning on the order page:
What exactly do you mean by order page? Can you be little more specific?

zbig

Quote from: prokops on March 30, 2016, 13:12:48 PM
The code suggestion took care of my issue, the only remaining thing is this warning on the order page:

QuoteWarning
500

Is this something experienced by others ?

I had exactly the same error. He always appeared after ordering. After correcting the orders.php it is OK

Milbo

I still wonder which property of the product starts with an empty char?
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Jumbo!

It is not exactly an empty character but "*_". See the screenshot attached. You can't have a property starting with *.

$item->*_tbl becomes $item->\0_tbl

Milbo

Ahh, I see, php7 adds a * for protected variables. Okey that explains it. I must admit, I did not work on the php7 compatibility, yet. Others work on it.

Does it work with if (!isset($item->$k) and '_' != substr($k, 0, 1) and '*_' != substr($k, 0, 1)) {
but without the trim?

I wonder if we should use a Constant to define if we search for _ or *, because the * sounds to be the future. The _ is just a convention, or?
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/