• Resolved Mike Kipruto

    (@mikekipruto)


    Hey team, I am getting the following PHP Warning: Undefined variable on PHP 8.1.28:

    PHP Warning:  Undefined variable $index in path-to-sitewp-content/plugins/diagnoseo/includes/class-diagnoseo-metatags.php on line 455
    PHP Warning: Undefined variable $index in path-to-sitewp-content/plugins/diagnoseo/includes/class-diagnoseo-metatags.php on line 456
    PHP Warning: Undefined variable $follow in path-to-sitewp-content/plugins/diagnoseo/includes/class-diagnoseo-metatags.php on line 457
    PHP Warning: Undefined variable $follow in path-to-sitewp-content/plugins/diagnoseo/includes/class-diagnoseo-metatags.php on line 458

    While troubleshooting, I found out that the Diagnoseo_MetaTags::meta_robots() method was producing the PHP warnings due to the use of undefined variables $index and $follownot being set when none of the if or elseif conditions were met, leaving these variables undefined when they were later used to set values in the $robots array.

    As a temporary fix to ensure that $index and $follow are always defined, they were initialized with default values at the beginning of the meta_robots method. Which I’ve added to fix the issue for me:

    public function meta_robots( $robots ) {
    $index = 'noindex'; // Default value
    $follow = 'nofollow'; // Default value

    I hope this helps, and please let me know if you need any clarification about the issue from my end.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author DiagnoSEO.com

    (@diagnoseo)

    Hey Mike,

    Thank you for your comment.

    It’s already fixed in the latest update.

    Hope this helps!

    Please let us know if we can be of further assistance.

    Thread Starter Mike Kipruto

    (@mikekipruto)

    Hey @diagnoseo, great to hear that.

    While running updates and testing on my staging site, I came across this notice:

    [16-Jul-2024 08:49:30 UTC] PHP Warning:  Trying to access array offset on value of type null in path-to-sitewp-content/wp-content/plugins/diagnoseo/includes/class-diagnoseo-metatags.php on line 44

    To fix it, I replace line 44 on my end with this one:

    self::$separator = get_option( 'diagnoseo_separator', $this->defaults['diagnoseo_separator'] ?? ' | ' );

    I am happy to report it, please let me know if I can open a GH issue or pass it here. Thank you

    • This reply was modified 4 months, 1 week ago by Mike Kipruto.
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.