• Resolved ArtGoddess

    (@artgoddess)


    Hi there,

    I’m afraid I can see this php warning in my sitemap page (frontend):

    Notice: Undefined variable: str in /home/user/domain.com/wp-content/plugins/wp-sitemap-page/wp-sitemap-page.php on line 477
    
    Notice: Undefined variable: str in /home/user/domain.com/wp-content/plugins/wp-sitemap-page/wp-sitemap-page.php on line 477

    WP 5.8.1, Plugin 1.8.0, PHP 7.4, debug mode on.

    Just in case it helps. Many thanks!

Viewing 15 replies - 1 through 15 (of 15 total)
  • Hello,

    In PHP 8.0.12 it is a warning:
    PHP Warning: Undefined variable $str in /wp-content/plugins/wp-sitemap-page/wp-sitemap-page.php on line 477

    olivelm

    (@olivelm)

    Hello,

    I have the same!
    That it is a simple warning, I am okay, but for the Net surfer it is not very pretty.
    Does anyone know how to get rid of it?

    thanks in advance

    rgierke

    (@rgierke)

    From the looks of it, lines 476 and 477 were copied from the above function on line 276 and 277, along with the rest of the array creation.

    As the $str variable on line 477 isn’t being used at all in that function, it could be commented out until the plugin is updated.

    Gal Baras

    (@galbaras)

    In fact, since wsp_wp_sitemap_page_main_func() filters the shortcode content using wsp_wp_sitemap_page_func(), lines 476-507 seem completely unnecessary.

    Commenting them out seems to be working OK.

    @funnycat, can you please release a fix for this?

    • This reply was modified 3 years ago by Gal Baras.
    • This reply was modified 3 years ago by Gal Baras.
    olivelm

    (@olivelm)

    Thank you all for your help.
    Commenting out lines 476 to 507, I have a different error message!
    Undefined variable $arr in /home/clients/23a0cf32c5b47c75c78ccdc7c193c655/web/wp-content/plugins/wp-sitemap-page/wp-sitemap-page.php on line 512
    I leave aside for now, hope for a fix in the near future.

    Gal Baras

    (@galbaras)

    Sorry, I forgot to check the error log.

    Yeah, the last line in wsp_wp_sitemap_page_main_func() (line 509, actually) should be this:

    return '<div class="wsp-container">' . wsp_esc_some_html_tags( wsp_wp_sitemap_page_func( $atts, $content ) ) . '</div>';

    This time, the log is clean and the page appears to be correct.

    Gal Baras

    (@galbaras)

    BTW, this could be caused by using the E_STRICT PHP error reporting flag. PHP doesn’t have any problems with undefined variables. It assumes they’re empty, casts them to the expected type and keeps going. But if strict error reporting is enabled, it reports them, although there are no execution problems.

    olivelm

    (@olivelm)

    Thanks a lot Gal, the problem is solved with your valuable advice.

    Gal Baras

    (@galbaras)

    Well, @funnycat should still release this fix for everyone to enjoy. Unfortunately, the respective code still looks the same in 1.9.0 ??

    olivelm

    (@olivelm)

    This is what I note with regret this morning…

    donsenilo1968

    (@donsenilo1968)

    Yep, I get the same errors.

    Plugin Author Tony Archambeau

    (@funnycat)

    Hello everybody.
    Thank you for these messages to let me know about this error. I just released a fix (version 1.9.1). Sorry about this mistake.
    Have a really nice day.
    Sincerely,
    Tony

    Thread Starter ArtGoddess

    (@artgoddess)

    Great! Many thanks @funnycat

    Malae

    (@malae)

    @funnycat

    Thank you Tony for the update, I fixed it myself, but glad you finally caught up with it.

    olivelm

    (@olivelm)

    Thank you so much Tony

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Undefined variable: str in wp-sitemap-page.php’ is closed to new replies.