Skip to content

Error when marking a message as spam in Flamingo. #162

@sdellenb

Description

@sdellenb

Description

I'm running into an error when marking a delivered CF7 message as spam in Flamingo.

This is the full call stack (domain replaced with placeholder the-website.com):

  thrown in /srv/www/sites/the-website.com/wp-c" while reading response header from upstream, client: 2a02:21b4:1a73:9101:a15e:31b5:a6ca:add1, server: www.the-website.com, request: "GET /wp-admin/admin.php?page=flamingo_inbound&post=2206&action=spam&_wpnonce=15b26b389b HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm.in-seminare.sock:", host: "www.the-website.com", referrer: "https://www.the-website.com/wp-admin/admin.php?page=flamingo_inbound"
2025/12/14 15:14:13 [error] 436262#436262: *201326 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught TypeError: CF7_AntiSpam\Core\CF7_Antispam_Blacklist::cf7a_ban_by_ip(): Argument #2 ($reason) must be of type array, string given, called in /srv/www/sites/the-website.com/wp-content/plugins/cf7-antispam/core/CF7_AntiSpam_Flamingo.php on line 118 and defined in /srv/www/sites/the-website.com/wp-content/plugins/cf7-antispam/core/CF7_Antispam_Blacklist.php:56
Stack trace:
#0 /srv/www/sites/the-website.com/wp-content/plugins/cf7-antispam/core/CF7_AntiSpam_Flamingo.php(118): CF7_AntiSpam\Core\CF7_Antispam_Blacklist::cf7a_ban_by_ip()
#1 /srv/www/sites/the-website.com/wp-includes/class-wp-hook.php(339): CF7_AntiSpam\Core\CF7_AntiSpam_Flamingo->cf7a_d8_flamingo_classify()
#2 /srv/www/sites/the-website.com/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters()
#3 /srv/www/sites/the-website.com/wp-includes/plugin.php(522): WP_Hook->do_action()
#4 /srv/www/sites/the-website.com/wp-admin/admin.php(242): do_action()
#5 {main}
  thrown in /srv/www/sites/the-website.com/wp-c" while reading response header from upstream, client: 2a02:21b4:1a73:9101:a15e:31b5:a6ca:add1, server: www.the-website.com, request: "GET /wp-admin/admin.php?page=flamingo_inbound&post=2206&action=spam&_wpnonce=15b26b389b HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm.in-seminare.sock:", host: "www.the-website.com", referrer: "https://www.the-website.com/wp-admin/admin.php?page=flamingo_inbound"

Problem

cf7a_ban_by_ip() declares $reason as array:

public static function cf7a_ban_by_ip( string $ip, array $reason = array(), $spam_score = 1 ): bool {
, but CF7_AntiSpam_Flamingo::cf7a_d8_flamingo_classify() sends a fixed string:
CF7_Antispam_Blacklist::cf7a_ban_by_ip( $flamingo_post->meta['remote_ip'], 'flamingo ban' );

Note: Line numbers differ from call stack because I'm on released version 0.7.2.

Solution

Changing the line to

CF7_Antispam_Blacklist::cf7a_ban_by_ip( $flamingo_post->meta['remote_ip'], ['flamingo ban'] );

solves the issue and makes the feature work again. I'll create a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions