Wordpress (multisite): 5.4.2
Following the setup docs (it got a tad confusing for this newbie when defining what LOGGING I wanted to be enabled (reference: https://docs.wp-fail2ban.com/en/4.3/configuration/logging.html)) - when coming to the COMMENTS_EXTRA define() instructions, some constants appear to be undefined (though I may have set things up wrongly).
Let me explain:-
Defining a constant as “true” within wp-config.php makes sense:-
… and this enables SPAM logging successfully.
Further in the page we’re advised to “You should consider enabling Comment: Spam and Attempted Comment: Closed post” … and following the docs on that constant (https://docs.wp-fail2ban.com/en/4.3/defines/constants/WP_FAIL2BAN_LOG_COMMENTS_EXTRA.html#wp-fail2ban-log-comments-extra) we’re advised to OR constants together as follows:-
define(‘WP_FAIL2BAN_LOG_COMMENTS_EXTRA’, WPF2B_EVENT_COMMENT_CLOSED | WPF2B_EVENT_COMMENT_DRAFT);
Presumable in the same wp-config.php file as the other logging-enabling constants.
PROBLEM: PHP (7.4) raises a warning that the “or”'d constants are not defined (so it goes ahead to assume they’re strings). Here’s the error log:-
Got error 'PHP message: PHP Warning: Use of undefined constant WPF2B_EVENT_COMMENT_CLOSED - assumed ‘WPF2B_EVENT_COMMENT_CLOSED’ (this will throw an Error in a future version of PHP) in /home/sites/wordpress-mu/web/wp-config.php on line 103
PHP message: PHP Warning: Use of undefined constant WPF2B_EVENT_COMMENT_DRAFT - assumed ‘WPF2B_EVENT_COMMENT_DRAFT’ (this will throw an Error in a future version of PHP) in /home/sites/wordpress-mu/web/wp-config.php on line 103’
COMMENTARY: My setup is using wp-fai2ban as an mu-plugin (via symbolic link). It looks like these constants don’t get defined before the setting is reached in wp-config.php (wp-fail2ban isn’t loaded yet?) So, these constants aren’t defined before the define() statment is reached in wp-config.php. Documentation assumes they are. So … my implementation error … or a bug in the documentation?