Author Topic: Error with PHP 7: Cannot access property started with '\0'  (Read 9284 times)

Roman_Magick

  • Beginner
  • *
  • Posts: 12
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

  • Beginner
  • *
  • Posts: 30
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #1 on: March 24, 2016, 06:22:54 am »
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

  • Beginner
  • *
  • Posts: 7
  • A beginner
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #2 on: March 24, 2016, 10:00:19 am »
Same here!

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

Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 672
  • Full-stack Web Developer
    • www.virtueplanet.com
  • VirtueMart Version: Always latest
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #3 on: March 24, 2016, 17:28:26 pm »
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:

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

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

Roman_Magick

  • Beginner
  • *
  • Posts: 12
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #4 on: March 24, 2016, 19:11:02 pm »
Jumbo's fix works for me. Thanks!

ThiloS

  • Beginner
  • *
  • Posts: 7
  • A beginner
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #5 on: March 25, 2016, 09:12:57 am »
jep. everything fine now with that extra line...

Thanks!

amlil71

  • Beginner
  • *
  • Posts: 30
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #6 on: March 25, 2016, 09:55:54 am »
Hello Jumbo,

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

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9919
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #7 on: March 27, 2016, 03:06:17 am »
would be interesting to have a vmtrace there to see which object creates the problem
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

zbig

  • Beginner
  • *
  • Posts: 8
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #8 on: March 29, 2016, 18:53:59 pm »
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

  • Jr. Member
  • **
  • Posts: 53
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #9 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:

Quote
Warning
500

Is this something experienced by others ?



Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 672
  • Full-stack Web Developer
    • www.virtueplanet.com
  • VirtueMart Version: Always latest
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #10 on: March 30, 2016, 13:25:42 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

  • Beginner
  • *
  • Posts: 8
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #11 on: March 30, 2016, 14:07:21 pm »
The code suggestion took care of my issue, the only remaining thing is this warning on the order page:

Quote
Warning
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9919
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #12 on: March 31, 2016, 23:14:37 pm »
I still wonder which property of the product starts with an empty char?
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 672
  • Full-stack Web Developer
    • www.virtueplanet.com
  • VirtueMart Version: Always latest
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #13 on: April 01, 2016, 10:00:50 am »
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9919
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Error with PHP 7: Cannot access property started with '\0'
« Reply #14 on: April 01, 2016, 12:24:57 pm »
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?
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/