PHP Warning: Illegal string offset ‘last’
-
Just want to give you a heads up. I’ve been seeing a lot of the following warnings the past few months in my PHP logs on all sites using WPForms.
[09-May-2023 01:32:25 UTC] PHP Warning: Illegal string offset ‘first’ in /home/customer/www/www….com/public_html/wp-content/plugins/wpforms-lite/includes/fields/class-name.php on line 508
[09-May-2023 01:32:25 UTC] PHP Warning: Illegal string offset ‘last’ in /home/customer/www/www….com/public_html/wp-content/plugins/wpforms-lite/includes/fields/class-name.php on line 512
-
Hi @chargeup,
Please know that I could not find an issue open for that PHP warning.
In case you’re not using WPForms version 1.8.1.x, it’s possible that this is either causing or contributing to the issues that you’re seeing, so we need to start updating your WPForms version. In case it helps, WPBeginner has a detailed tutorial on how to update plugins on your site.
If you’re using WPForms 1.8.1.x, could you please share a few details that I can use to replicate this issue? Also, please let me know your WordPress, WPForms and PHP versions. That way, we can try to reproduce the issue and investigate it.
I’m looking forward to your response.
Thanks!
Hi @chargeup,
We tried to reproduce the issue, but we had no success.
From previous alert warnings like this, we saw some situations where the issue was due to a custom code snippet, especially in the theme’s functions.php file.
Could you please verify custom code snippets on your site, especially in functions.php?
Thanks, and please let me know!
Thanks for the quick response. Here is the system information:
Begin System Info -- WPForms Info Lite: Aug 16, 2022 @ 4:17pm Lite Connect: Backup is enabled since Aug 19, 2022 @ 1:44pm -- Site Info Site URL: https://www...com Home URL: https://www...com Multisite: No -- WordPress Configuration Version: 6.2.2 Language: en_US User Language: en_US Permalink Structure: /%postname%/ Active Theme: Astra Child 1.0.0 Show On Front: page Page On Front: Home (#105) Page For Posts: Unset ABSPATH: /home/customer/www/www....com/public_html/ Table Prefix: Length: 4 Status: Acceptable WP_DEBUG: Disabled WPFORMS_DEBUG: Not set Memory Limit: 256M Registered Post Stati: publish, future, draft, pending, private, trash, auto-draft, inherit, request-pending, request-confirmed, request-failed, request-completed Revisions: Enabled -- WordPress Uploads/Constants WP_CONTENT_DIR: /home/customer/www/www...com/public_html/wp-content WP_CONTENT_URL: https://www...com/wp-content UPLOADS: Not set wp_uploads_dir() path: /home/customer/www/www...com/public_html/wp-content/uploads/2023/05 wp_uploads_dir() url: https://www...com/wp-content/uploads/2023/05 wp_uploads_dir() basedir: /home/customer/www/www...com/public_html/wp-content/uploads wp_uploads_dir() baseurl: https://www...com/wp-content/uploads -- WordPress Active Plugins Astra Pro: 4.1.5 Contact Form Entries: 1.3.1 Elementor: 3.13.3 Elementor Header & Footer Builder: 1.6.14 SiteGround Optimizer: 7.3.1 SiteGround Security: 1.4.5 WP Armour - Honeypot Anti Spam: 2.1.4 WPForms Lite: 1.8.1.3 WP Mail SMTP: 3.8.0 WP Rocket: 3.13.3 Yoast SEO: 20.8 -- WordPress Inactive Plugins Elementor Pro: 3.7.3 Gravity Forms: 2.6.5 iThemes Security Pro: 7.1.3 -- Webserver Configuration PHP Version: 7.4.33 MySQL Version: 5.7.39 Webserver Info: Apache -- PHP Configuration Memory Limit: 768M Upload Max Size: 256M Post Max Size: 256M Upload Max Filesize: 256M Time Limit: 120 Max Input Vars: 3000 Display Errors: On (1) -- PHP Extensions cURL: Supported fsockopen: Supported SOAP Client: Installed Suhosin: Not Installed -- Session Configuration Session: Disabled End System Info
There aren’t any custom snippets or custom code in the functions.php file and I’m using Astra.
I’ve also checked the access logs and the timestamp is indeed matching up for when the form attempt is happening.
However, the form doesn’t get submitted and there aren’t any entries.
It looks like the warning revolves around extended validation in the code from that particular file.
// Extended validation needed for the different name fields.
Could this just be a spammer attempting to enter code or something else into that field and it’s triggering the warning? I’m just thinking out loud.
Hi @chargeup,
Thanks for all the information!
It’s weird because looking at the lines 508 and 512 in the class-name.php file, it’s just a doc block, and here’s a screenshot: https://a.supportally.com/i/gziXrp.
Looking at the system information, we could see some third-party plugins that might be related to the issue.
When you get the chance, could you please try using the steps in WPBeginner’s detailed guide on troubleshooting WordPress to see if it helps resolve the issue?
Thanks!
It looks like there might be a conflict between the forms and the site theme or another plugin. In this case, you can also try the steps described in our detailed guide on how to test for plugin/theme conflicts.
Hope this helps!
My apologies. I actually pulled that from a staging site using 1.7.8. The code snippets are the same. 508 in that version is the exact same as line 526 & 530 in 1.8.1.3.
I’m not sure your assessment of it being a theme or plugin issue is accurate. I know this is a pretty common response from every theme and plugin author I’ve used. I use WPForms on all types of sites with different themes and plugins. I have gotten the same warnings for quite some time across pretty much all of my sites.
May or may not be a similar issue but here is another user who reported a similar bug from a different file about 2 years ago. You found the issue on that file so might be worth taking a deeper look.
Hi @chargeup,
If I correctly understood, the PHP warnings came from WPForms version 1.7.8. Could you please confirm if you were able to reproduce the issue using the version 1.8.1.3?
This issue should not happen with WPForms 1.8.1.x. Similar the topic that you shared, where the issue was with WPForms 1.6.3.1, and it was fixed on 1.6.4.
But if you can reproduce the issue on WPForms 1.8.1.3, could you please share a few details on how I can reproduce this issue? If possible, please share a video showing your steps to generate the PHP warning.
Thanks, and please let me know!
Hey @chargeup – I’m Prashant filling in for Ralden as he’s currently unavailable. We haven’t heard back from you in a few days, so I’m going to go ahead and close this thread for now. But if you’d like us to assist further, please feel welcome to continue the conversation.
Thanks!
Just want to let you know everything is up-to-date and the error is still present. WPForms is at version 1.8.1.3. I have no idea how to reproduce it. I have tried. I’m assuming it has something to do with bots. Maybe the other topic I shared is a good way to reproduce it on your end.
Here is the latest error I received:
PHP Warning: Illegal string offset ‘first’ in /home/customer/www/www…com/public_html/wp-content/plugins/wpforms-lite/includes/fields/class-name.php on line 527
Hey @chargeup – Thanks for following on this ticket!
When you have sometime, can you please share the export copy of the form so we can do some testing?
Kindly,
I’ve downloaded the form. However, it doesn’t look like there is a way to upload the json file here. Any suggestions?
Hey @chargeup – Thanks for your intrest in this ticket!
You can use file sharing tools like Google Drive orDropbox to upload the file, and share the URL here.
Kindly,
Hi @chargeup,
Thanks for sharing the form. However, I was not able to reproduce any PHP warning related to WPForms.
I created a new local site to try your form, and the only error logs were related to the Astra theme. For your reference, I created this screencast.
It looks like there might be a conflict between the forms and your Pro version of the Astra theme or another plugin. To troubleshoot this, please try the steps described in our detailed guide on how to test for plugin/theme conflicts.
Hope this helps!
- The topic ‘PHP Warning: Illegal string offset ‘last’’ is closed to new replies.