• Resolved mlstudies

    (@mlstudies)


    Hi John,

    Nice and simple plugin, thanks. I updated my site to PHP 8.2 and get the following warning : Warning: Undefined array key “selectedSlideshow” in?/home/clients/61f81534836c301ef655228e8839a9a3/web/wp-content/plugins/slideshow-se/src/block.php?on line?12

    I have to go back to 7.4 for now. Anything I should be doing on my end?

    Best regards

    Bill

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author John West

    (@f1rehead)

    I haven’t tested it for PHP 8, but I will and get back to you. Sounds like a language change that I’ll need to fix. Thanks for the heads up.

    Plugin Author John West

    (@f1rehead)

    I can’t replicate the issue. Do you have any slideshows on your site already, or is this a new install?

    Thread Starter mlstudies

    (@mlstudies)

    It’s a replacement for the previous slideshow plugin that has been discontinued. I flipped back to PHP 8.2 and have the same error message. The slides are working fine though. https://mlstudies.ch

    Here’s what ChatGPT says about it:

    Warning: Undefined array key “selectedSlideshow” in /home/clients/61f81534836c301ef655228e8839a9a3/web/wp-content/plugins/slideshow-se/src/block.php on line 12ChatGPT

    If you are encountering an “Undefined array key” warning specifically in the file /home/clients/61f81534836c301ef655228e8839a9a3/web/wp-content/plugins/slideshow-se/src/block.php on line 12, you should follow a similar approach as mentioned earlier to handle undefined array keys. Here are some steps you can take:

    1. Check if the Key Exists: Before accessing the array key, make sure it exists in the array. Use isset() or array_key_exists() to perform this check.php

    if (isset($yourArray['selectedSlideshow'])) { $value = $yourArray['selectedSlideshow']; } else { $value = 'default_value'; }

    Or using array_key_exists():

    php

    if (array_key_exists('selectedSlideshow', $yourArray)) { $value = $yourArray['selectedSlideshow']; } else { $value = 'default_value'; }

    Use Null Coalescing Operator (PHP 7+): If you are using PHP 7 or later, you can use the null coalescing operator (??) for a more concise way of handling undefined keys.

    php

    $value = $yourArray['selectedSlideshow'] ?? 'default_value';

    Check for Array Existence: Verify that the array itself is defined before attempting to access its keys.

    php

    if (isset($yourArray) && is_array($yourArray)) { $value = $yourArray['selectedSlideshow'] ?? 'default_value'; } else { // Handle the case when the array is not set }

    Debugging: Use var_dump() or print_r() to inspect the structure of the array and see which keys are available.

    php

    1. var_dump($yourArray);

    Apply these approaches to the specific line (line 12) in your block.php file to ensure that you handle undefined array keys appropriately, either by setting default values or by checking for their existence before use.

    Plugin Author John West

    (@f1rehead)

    I know how to fix it, but I can’t replicate the issue. I’m normally not keen to make changes unless I can see the problem, but this is a pretty harmless fix. But I can’t test it so I’ll go ahead and make the release and push it out. Let me know if it solves your problem.

    Thread Starter mlstudies

    (@mlstudies)

    Thanks John. I updated the PHP to 8.2 and it all works perfectly. Many thanks for your great support!

    Plugin Author John West

    (@f1rehead)

    Glad to hear it. Thanks for using the plugin!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Support for PHP 8+ ?’ is closed to new replies.