This is a legitimate php 7 issue.
Line 884 is:
$$meta['key'] = $meta['value'];
and should be:
${$meta['key']} = $meta['value'];
I have spent about 8 hours tracking down this issue and would appreciate seeing it fixed.
Hi vincentatsc,
I don’t program in PHP, but that looks like a fix (if it works).
Did it work for you after you edited the correction?
The developer will probably notice you contribution shortly.
Thanks for your help.
Yes, that fixed importing menu items in php 7.
This issue has been brought up a few times in the support forums, hopefully the author updates the code as php 7 is used more frequently.
Hi vincentatsc,
1) Is the
$$meta[‘key’] = $meta[‘value’];
ok syntax for earlier versions of PHP?
(If it is not, then this should be fixed anyway.)
2) The plugin could make use of methods for detecting the php version, and using different code depending on the version that is detected.
Thanks
http://php.net/manual/en/language.variables.variable.php
Curly braces may also be used, to clearly delimit the property name. They are most useful when accessing values within a property that contains an array, when the property name is made of mulitple parts, or when the property name contains characters that are not otherwise valid (e.g. from json_decode() or SimpleXML).
It appears the syntax is well supported in php 5.6 and I suspect earlier minor versions.
Hi vincentatsc,
1) Is the
$$meta[‘key’] = $meta[‘value’];
ok syntax for earlier versions of PHP ??
If it is ok to use this in earlier php versions, and the code still work, then this is only a problem with later versions.
3) If the ${$meta['key']} = $meta['value']; curly bracket form of the code works in all php versions, then there is no harm in using that for all, and it fixes the problem.
So, is the curly bracket form, backward compatible with earlier php versions?
Thanks
Hi,
I have the same message on line
772 | ERROR | Indirect access to variables, properties and methods will be evaluated strictly in left-to-right order since PHP 7.0. Use curly braces to remove ambiguity.
—————————————————————————————-
my lines in wordpress-importer.php from 771 :
// Create an array to store all the post meta in
$menu_item_meta = array();
foreach ( $item[‘postmeta’] as $meta ){
$$meta[‘key’] = $meta[‘value’];
Could you help me plese ? What should I change ?
Thank you !!
$menu_item_meta[$meta[‘key’]] = $meta[‘value’];
}
MKSnMKS the curly brace form I posted is backwards compatible, though I haven’t personally tested it.
wiaofim, as I posted earlier in this thread:
$$meta[‘key’] = $meta[‘value’];
should be
${$meta[‘key’]} = $meta[‘value’];
Note the curly braces around $meta[‘key’]
-
This reply was modified 8 years, 7 months ago by
vincentatsc.
Thanks vincentatsc.
Hopefully the plugin author(s) will fix this sometime soon.
This Bug is know by the worpress team sinc 1 year and 9 month! There is also a fix provided for the latest version of the plugin.
https://core.trac.ww.wp.xz.cn/ticket/36281
Hopefully, this will be fixed soon! But after almost 2 years, in which this error is known, I doubt that…
Hi blafasl,
Thanks for that.
Yes – hopefully it will be fixed soon.
Maybe they take 1 year and 10 months to implement fixes.
Here’s hoping.
Is there any way we can encourage them to fix this?
Thanks
Today we released version 0.6.4 of the WordPress Importer which includes a fix for this issue.
Hi Dominik Schilling (ocean90) (@ocean90),
Thank you for doing that.
I updated it earlier today.
I ran a PHP compatibility check in the last few days,
so will have missed the recent update.
I will be scanning again within a month (hopefully),
for PHP 7, and up.
If you can, it might be helpful to know why this problem existed for so long, so would you be able to maybe give a story or a (bullet point) list of contributing factors?
And maybe some thoughts or suggestions on how things might be able to be improved to help assist the development of plugins?
Thank you