• Resolved timjh

    (@timjh)


    I occasionally get this PHP error message: “Undefined offset: 0 in …/wp-content/plugins/automatic-alternative-text/automatic-alternative-text.php on line 297”

    The line number is “wrong” because I’ve inserted some instrumentation code, but the problem line is

    $caption = $response_body[‘description’][‘captions’][0] ?: false;

    It appears that Cognitive Services can occasionally return a 200 response but with no suggested caption. I’m using PHP 7.2 so my fix is easy: replace “?:” with “??”. For PHP 5, it needs an explicit “isset”, I think.

    • This topic was modified 5 years, 8 months ago by timjh.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Undefined offset: 0’ is closed to new replies.