Author Topic: 0 - Cannot access property started with '\0' while accessing product page  (Read 714 times)

goudmahendra

  • Beginner
  • *
  • Posts: 35
  • A beginner
Hello Support,

I have joomla 3.6.5 virtuemart 3.0.18.

I have upgraded my php version to 7 and since upgradation when I click on product on product listing page to get detail page I have got the following error.

0 - Cannot access property started with '\0'

Please help me to solve this issue. I have tried jumbo! solution on following post

http://forum.virtuemart.net/index.php?topic=133607.0

But its not work for me.

Please help.

Thanks

GJC Web Design

  • 3rd party VirtueMart Developer
  • Hero Member
  • *
  • Posts: 7485
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.2
you can try VM3.2 -- test first!!
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

opn365

  • Beginner
  • *
  • Posts: 2
  • A beginner
  • Skype Name: sirobertson
HI
I am having the same issue  when update to php 7 on one site  joomla 3.71  VM 3.22

The only workaround seems to be staying on php 5.6  which is not a good option

Does anyone have any fix for this yet or even a clue?

Thanks and Regards
Stuart
opn365.com


Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 567
  • Software Developer {PHP, JavaScript, jQuery, ...}
    • www.virtueplanet.com
  • VirtueMart Version: 3.2.2
Does your site has products with multi-variants or child products?

opn365

  • Beginner
  • *
  • Posts: 2
  • A beginner
  • Skype Name: sirobertson
Does your site has products with multi-variants or child products?

Yes - does that make a difference some way?

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26029
  • Always on vacation
    • Jenkin Hill Internet
The only workaround seems to be staying on php 5.6  which is not a good option

PHP5.6 will receive security support until 31 Dec 2018   
PHP7.0 will receive security support  until 3 Dec 2018

So having to use 5.6 for longer while you solve the issue is a reasonable option.

See https://forum.virtuemart.net/index.php?topic=133607.0    I have had no issues with PHP7 and latest versions.
Kelvyn

Jenkin Hill Internet,
Keswick, Lake District

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM3.2.3.9579 on Joomla 3.7.3 PHP 7.0.19

Testing VMVM3.2.4 on J!3.7.3

Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 567
  • Software Developer {PHP, JavaScript, jQuery, ...}
    • www.virtueplanet.com
  • VirtueMart Version: 3.2.2
Try this.

Open - administrator/components/com_virtuemart/models/product.php

Find the following codes between lines 998 to 1006:

Code: [Select]
foreach ($attribs as $k=> $v) {
if (strpos($k, "\0")===0) continue;
if ('product_in_stock' != $k and 'product_ordered' != $k) {// Do not copy parent stock into child
if (strpos ($k, '_') !== 0 and empty($child->$k)) {
$child->$k = $v;
// vmdebug($child->product_parent_id.' $child->$k',$child->$k);
}
}
}

Replace above by:

Code: [Select]
foreach ($attribs as $k=> $v) {
if (strpos($k, "\0")===0) continue;
if ('product_in_stock' != $k and 'product_ordered' != $k) {// Do not copy parent stock into child
if (isset($parentProduct->$k) && strpos ($k, '_') !== 0 && empty($child->$k)) {
$child->$k = $v;
// vmdebug($child->product_parent_id.' $child->$k',$child->$k);
}
}
}

Save the file. Now check again.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9085
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
I wonder that the problem is not catched by the
Code: [Select]
if (strpos($k, "\0")===0) continue;
above
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

diri

  • Beginner
  • *
  • Posts: 27
Milbo, I might be wrong but, in my understanding you're checking for NULL character and you must have a strlen of 1 for this at least.

I don't believe it being reliable (in no language).

Checking via isset and empty checks variable set and empty checks for an empty string.

In some languages one can do if (strlen(var) + 0) to overcome some nasty hurdles being imposed by is NULL, is empty and the like.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9085
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
It is a key, retrived before by get_object_vars, so it must be set. I wonder how to set an empty property to a class, I doubt that can work. The check for "\0" is for php7 to check if it is a protected or private property.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

diri

  • Beginner
  • *
  • Posts: 27
hm.

give such a construct a try, please:

$a = "";
$b = "\0";

echo "strlen a: " . strlen($a);
echo "strlen b: " . strlen($b);

Over here I get strlen a = 0, strlen b= 1.

edit:
C handles strings with \0 per automatic (NULL termination), PHP does not (AFAIR).

edit2:
You can find "mysterious" results with SQL in same relation as well when you don't use COALESCE.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9085
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
The array which is used for the foreach is created by "get_object_vars". Try to create a attribute for an object, which is is an empty string. Imagine the code
Code: [Select]
$myObject->{}="TEST";
I doubt that can work.

But we could extend and write
Code: [Select]
if (empty($k) or strpos($k, "\0")===0) continue;
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

aftertaf

  • Jr. Member
  • **
  • Posts: 97
    • sO couture
  • VirtueMart Version: 3.2.2
are you using a debian/linux server? If so, list the packages you have installed for php7.x.
dpkg -l | grep php7

Here is the list of my packages...
I remember when i moved to php7 i had issues, and i solved them by adding more packages (upgrade didnt install all the ones that were needed...

php7.0         
php7.0-bz2     
php7.0-cgi     
php7.0-cli     
php7.0-common 
php7.0-curl   
php7.0-fpm     
php7.0-gd     
php7.0-json   
php7.0-mbstring
php7.0-mcrypt
php7.0-mysql
php7.0-opcache
php7.0-readline
php7.0-xml

just in case it helps...
Webmaster for my wife
Long live joomla, virtuemart and open source in general.
usually latest version of VM & J!
Using POSForWebshops, TemplatecreatorCK, MaximenuCK, VM BatchEdit Pro among other things...
VM 3.2.2, PHP Version 7.0.18-1~dotdeb+8.1, mariadb 10.1.22 Joomla! 3.7.2

diri

  • Beginner
  • *
  • Posts: 27
There's something I "like" since very first days of PHP:

No version has reliable and complete documentation and with no version one can trust on it's compatibility to it's predecessor ...  :'(

Any update can be an adventure forcing you to dive very deep. Therefore I'm happy to have Perl available most time.

diri

  • Beginner
  • *
  • Posts: 27
Ah, forum works again (it had some 502 hickups)...

Ok, i fear there's a basic problem with $var is either null, empty or 0. ISSET seems to have nothing to do with it at first glance.

Didn't check in real detail now, but (if memory serves well) EMPTY should not return an error in case you try to access a private variable. It returns "true" in such a case. If it's a public string variable with value 0 it returns true as well.

There are some pitfalls with isset in PHP because i.e. in case get_object_vars returns a value instead of a var and __get is used internal by PHP isset returns false.

In my humble oppinion this behaviour is reason for working combination of empty and comparison of variable ($k in this case).

I doubt it's working reliable because when there is a private var you don't have anything to compare and current (not extended) implementation works correct like being designed:
No var -> no comparison.