What versions of CF7 and PHP are you using?
Is there a stack trace?
Are you using any custom code or addon besides CF7?
Can you replicate this at will? If so, how?
Hello,
We use the latest CF7 version, and PHP 8.1.
We do not know the trigger of the issue.
Is there a stack trace?
Are you using any custom code or CF7 addon?
The function calling preg_replace() is wpcf7_strip_whitespaces(), and the 3rd argument is the value of a field, most likely called as part of form sanitization and validation during submission. So maybe some filter function is setting a field value to null?
Hello
There is no Stack Trace.
We are also using Honeypot for Contact Form 7.
We do not have any custom code.
-
This reply was modified 1 year, 2 months ago by
balvan64.
Can you test which form produces the error and provide the details? Basically, submit each form in turn and see which one writes to your error log.
We have only a single form.
Nobody can help you without information, so I’m going to stop trying.
I’m not sure which details you asked which I did not provide.
The URL of the page, what triggers the problem, and the details of the form itself. Also, any other error log messages that could be related (typically before or after the one you’ve shared).
This issue seems to be unique to your setup, so try to find any relevant information that might make your website a special case.
You could also try performing a plugin and theme isolation test by switching to one of the default WordPress themes and deactivating all the plugins, except Contact Form 7. You can do this with the Health Check & Troubleshooting, so as not to lose any setup.
Hello,
I do not see this issue in the log for a few days now, not sure why. Today I tried to submit the form empty, as the issue is passing null to the function, and that resulted in this in the log:
[24-Jan-2025 19:22:19 UTC] PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/aaa/public_html/wp-includes/kses.php on line 1805
This is the form: https://www.japanese-knives.co.il/contact-us/
Doing an isolation test won’t help, as you already said you cannot see such an issue, so if I convert our website into an empty website with only the contact form 7 plugin and some of the generic themes, I would see the same thing that you see for certain.
-
This reply was modified 1 year, 2 months ago by
balvan64.
-
This reply was modified 1 year, 2 months ago by
balvan64.
Seems to me this is because the email field is optional, and the plugin can’t work without an email address. Validations work find for all the required fields, and the form seems to be set up OK otherwise.
Try making the email field required. This should solve the problem.
בהצלחה!
I do not want to require email, now I see that if I do not require it, submitting the form without it results in an error.
is there a way to avoid this?
I would suggest opening an issue on https://github.com/rocklobster-in/contact-form-7/issues. What you’re doing might make sense in your very specific case, but unlikely to be relevant for anyone else.
Another thing you can do is test other plugins. Since you only need one simple form, any plugin that supports your need will do.
Or you could code a form, and add it as a shortcode into the page, but this will need to be done with proper security measures and proper validation.
But the simplest and cheapest thing is to require the email address, even as a way to confirm that the person inquiring is real (it’s standard practice to send an automatic confirmation message, and if you get a sending failure, they’re not).