• Resolved Ângelo Antunes

    (@angelocampia)


    Hi FluentSMTP team,

    I’m using the latest version of FluentSMTP on my WordPress site and I noticed a PHP warning being logged repeatedly:

    PHP Warning:  Undefined array key "state" in /wp-content/plugins/fluent-smtp/app/Hooks/actions.php on line 29

    After checking the code, it seems the warning comes from this line:

    $state = $_REQUEST['state'];

    This line is located inside a permission_callback function in the rest_api_init hook for the /fluent-smtp/outlook_callback/ endpoint. The warning occurs when the state parameter is not present in the request, which causes PHP to throw a warning due to accessing an undefined array key.

    I’m running PHP version 8.2.21 (64-bit support), where such access without checking existence triggers a warning.

    To improve compatibility with PHP 8+, I suggest modifying the line to:

    $state = $_REQUEST['state'] ?? null;

    Or alternatively:

    $state = isset($_REQUEST['state']) ? $_REQUEST['state'] : null;

    This would prevent the warning while preserving the intended OAuth security check.

    Thanks in advance for looking into this!

    Best regards,
    Ângelo Antunes

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Ibrahim Sharif

    (@ibrahimsharif)

    Hello @angelocampia,

    Thank you for bringing this PHP warning to our attention and providing such a detailed analysis! We really appreciate you taking the time to investigate the issue and suggest a potential solution.

    Your technical insights regarding the “Undefined array key” warning in actions.php on line 29 are very helpful. We acknowledge that the current code could benefit from an update to improve compatibility with PHP 8+ and prevent the warning when the ‘state’ parameter is missing from the request.

    As you know, FluentSMTP is an open-source project. We are always happy to have community involvement! You can submit a Pull Request with your suggested fix on our GitHub repository: https://github.com/WPManageNinja/fluent-smtp. We would be very happy to review and merge it in.

    In the meantime, I have also forwarded your detailed report and suggested solutions to our development team for review and consideration. They will evaluate the best approach to address this issue in a future update.

    Thanks again for your valuable contribution to FluentSMTP!

    I’m seeing hundreds of this exact error in my php-fpm logs.

    I assume the fix provided by Ângelo has not yet been implemented?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘PHP Warning: Undefined array key “state” in actions.php on line 29’ is closed to new replies.