Support » Plugin: WP Realtime Sitemap » PHP7 Compatibility issue

  • Hi 🙂

    Your plugin have a compatibility issue with last version of php.

    You use dynamic variables names like this :
    $$all_options['first_order']

    but it is ambigous like explained here : http://php.net/manual/en/language.variables.variable.php

    In order to use variable variables with arrays, you have to resolve an ambiguity problem. That is, if you write $$a[1] then the parser needs to know if you meant to use $a[1] as a variable, or if you wanted $$a as the variable and then the [1] index from that variable. The syntax for resolving this ambiguity is: ${$a[1]} for the first case and ${$a}[1] for the second.

    Consequence : sitemap is not displayed and a lot of notices are displayed on frontend and backend settings page.

    The solution is to replace the code by :

    ${$all_options['first_order']}

    https://wordpress.org/plugins/wp-realtime-sitemap/

Viewing 7 replies - 1 through 7 (of 7 total)
  • I think this issue causes the problems listed here : https://wordpress.org/support/topic/sitemap-does-not-work-any-more?replies=5

    Plugin Author Rincewind

    (@rincewind)

    I have no access at the moment to PHP 7, and so am unable to test, verify and/or fix any issues that may or may not work with that version. Until such time as I do it will stay as it is, if someone would like to fix the issues for the benefit of themselves and other users feel free, if they was to contact me via email with the code I would be happy to commit it to the svn and give them credit for the fixes.

    Thank you for your answer. I understand. I hope that you’ll be able to test this great version soon :).

    Out of curiosity, could you use AMPPS or MAMP to spin up a PHP7 environment for testing?

    Based on the feedback of @ajoah, this update to line 1774 technically makes the plugin work in PHP7 :

    return ${$all_options['first_order']} . ${$all_options['second_order']} . ${$all_options['third_order']} . ${$all_options['fourth_order']} . ${$all_options['fifth_order']} . ${$all_options['first_order']} . $all_options['seventh_order'] . $promote;

    One non-fatal error still exists :

    Methods with the same name as their class will not be constructors in a future version of PHP; WPRealtimeSitemap has a deprecated constructor in wp-realtime-sitemap/wp-realtime-sitemap.php on line 32

    • This reply was modified 1 year, 8 months ago by  axlright.
    • This reply was modified 1 year, 8 months ago by  axlright.
    • This reply was modified 1 year, 8 months ago by  axlright. Reason: fix typos
    • This reply was modified 1 year, 8 months ago by  axlright. Reason: fix typos

    Likewise, I’m a user of WP Realtime Sitemap and am preparing for an upgrade to PHP7. I’d like to add my vote to an update that is compatible. Thanks in advance!

    Plugin Author Rincewind

    (@rincewind)

    v1.5.7 now fully works with php 7.

    You have @gingalley for providing the php 7 hosting and also myself to thank for this!

    If you would like to make a donation, you can do so here : http://goo.gl/mmUuGj

    This is entirely optional, but does mean that I am able to spend more time providing support and fixing issues than I would normally as working on this plugin doesn’t pay the bills.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘PHP7 Compatibility issue’ is closed to new replies.