freak3dot / wp-smart-honeypot

Wordpress plugin to reduce comment spam with a smarter honeypot.
MIT License
27 stars 4 forks source link

error in wordpress comment #2

Open nomada-rodrigo opened 8 years ago

nomada-rodrigo commented 8 years ago

hi! it keeps saying name or email address required, as those are the required fields, even when they are filled in. Maybe since the latest wordpress update. http://nf.focoempatico.net/

freak3dot commented 8 years ago

Did you have it installed and working before the latest Wordpress update? I have it installed and working on a website with Wordpress 4.3.3

nomada-rodrigo commented 8 years ago

Yes. It was working well.

On 02/04/2016 04:04 PM, Ryan Johnston wrote:

Did you have it installed and working before the latest Wordpress update?

— Reply to this email directly or view it on GitHub https://github.com/freak3dot/wp-smart-honeypot/issues/2#issuecomment-179918556.

cferdinandi commented 8 years ago

@freak3dot @nomada-rodrigo It seems like WordPress moving the Comment field to the top of the comment form is causing the breakage here. When I print out what gets submitted and then modified as part of the wpcsh_pre_post() function, the scrambled ID for the Comments field is wrong, and so it thinks the comment box is empty.

I've tried to fix this, but I just don't have enough understanding of how things are working under the hood to make it work.

freak3dot commented 8 years ago

Looks like @nomada-rodrigo is using WordPress 4.4.2.

@cferdinandi What version of WordPress are you using?

Maybe something with 4.4

cferdinandi commented 8 years ago

I'm also on 4.4.2. In 4.4 they started loading the Comments field above the name/email/website fields, supposedly because it's a better UX for the user. I'm wondering if this is causing the conflict?

screen shot 2016-03-23 at 6 10 45 pm

I'll get you a dump of what's happening shortly.

cferdinandi commented 8 years ago

I turned on debugging in WordPress, and I get this error:

Notice: Undefined index: 32874d4565d80ac32b6e9d5e1c626831 in /Users/cferdinandi/Sites/wordpress/wp-content/plugins/tarpit/tarpit-methods.php on line 96

I wrapped your stuff in a plugin, so this equates to line 229 in your PHP file.

I set it up to print the $_POST contents in the wpcsh_pre_post function. Here's what I'm seeing:

Array
(
    [06d4cd63bde972fc66a0aed41d2f5c51] => Some dummy comment text
    [comment] => 
    [e0ed3681b4252bc2ed2ee1e601faa33e] => Chris
    [ee1b46564672a323a150cebae2e46d13] => fake@email.com
    [5cdf7a3b86b682f1d9c3e4c3daded0c7] => http://example.com
    [submit] => Submit Comment
    [comment_post_ID] => 1
    [comment_parent] => 0
    [enc-type] => ZjBkYTRhMA==
    [author] => Chris
    [email] => fake@email.com
    [url] => http://example.com
)

Obviously the numbers change each time since they're randomly generated, but the undefined index seems to be correlated to the comment field, since that comes back empty every single time.

I also get this error, which makes no sense since the name and email fields are both coming through with content:

ERROR: please fill the required fields (name, email).

I've tried adjusting the insertAt == numbers, shifting them all up one, except for the comments which I set to 0 since it occurs first, but that throws multiple Notice: Undefined index errors on the comment form itself. It's specifically the 0 in the wpcsh_encrypt_comment function that causes this.

I also tried bumping comments up to the front of the array in protected $label_list, but that didn't change anything. I'm hoping this can help you debug what's going on here, as I'm officially at a loss.

One other point of note: you can use global $wp_version to get the version number being run and conditionally run some code.

Please let me know if there's anything else I can do to help you with this.

freak3dot commented 8 years ago

wpcsh_pre_post() is supposed to take all the obscured fields and map them back to their correct names in the $_POST global.

It leaves the obscured fields in the list. It could probably be made better by removing them.

cferdinandi commented 8 years ago

@freak3dot I figured that's what was happening, but for someone reason from WP 4.4 on it's not properly mapping the comments field (and oddly throwing errors on email/name). Any idea why that might be occurring? I'm thinking it has something to do with the new layout of the comments form.