Formatting.php error
-
Hi,
On my website, there is an error that comes up just before a commenters name on a post that reads:
Warning: strlen() expects parameter 1 to be string, object given in /home/content/60/10837160/html/ugometrics/web/wp-includes/formatting.php on line 1820
This error is visible on this page but so far that’s the only place I can see it. As for the the piece of code the error is referring to it is as follows:// Test for the minimum length the email can be if ( strlen( $email ) < 3 ) { return apply_filters( 'is_email', false, $email, 'email_too_short' ); }
specifically the “if” line. I also checked for the user on the database and it seems there is no one called “VICTOR”. Does anyone have any idea what the error might mean?
-
Warning: strlen() expects parameter 1 to be string, object given in /home/content/60/10837160/html/ugometrics/web/wp-includes/formatting.php on line 1820
This is a warning, not a fatal error. This also suggests that you are probably running your production site with DEBUG set to true.
One thing you’ll want to do if that’s the case is change
define('WP_DEBUG', true);
to
define('WP_DEBUG', false);
in
wp-config.php
.Next item, it only appears to be happening to a single user’s comments, so you might look in the wp_comments table and see if there’s something odd about his record. The warning is saying that WordPress expects
$email
to be a string and it isn’t.Finally (or firstly), you should try temporarily deactivating all plugins and changing to a default WordPress theme like TwentyThirteen to see if the problem persists (the Safe Mode plugin is handy for that if you don’t want to do it manually).
I installed the “dinky” theme on a vanilla WordPress 3.6.1 install and I’m not seeing that the function that the code you posted is in is even being called, which makes me wonder if a plugin or theme is involved.
Thank you very much for your help and reply, Doug. I will try out your suggestions and get back to you with the results.
If you do have DEBUG set to true, then setting it to false is about all you need to do. Unfortunately, a lot of plugins will display warnings if DEBUG mode is set to true. This is different from an error (or at least a fatal error). For security reasons, it’s best to never run a production site with DEBUG set to true. Good luck!
Hi, Doug. I have tried your suggestions. Debug mode was already set to false, I was really hoping that was it. I also tried loading the page in safe mode and the problem disappeared, I was really hoping that wasn’t it. Now I guess I have to look through every possible plugin? Also, I noticed the pattern, it’s not something with that specific commenter but with all commenters that don’t sign in, i.e. comment in the guest mode available on the site. Will looking at the wp_comments table still be worth it and if so is there any other way of accessing it with more details other than from the dashboard?
Thank you very much again for your attention.
If you’re not using a default theme, I’d try changing that first, since it’s simple and fast (unless you’re already using an unmodified WordPress default theme). Otherwise, you’ll have to try and narrow down which plugin, which you’ll have to do one at a time. I generally deactivate them all and then reactivate one at a time. Normally with DEBUG mode set to false, you won’t see the warning messages.
Narrowing it down to non-logged in commenters may help solve the puzzle as well (I’m going to look at that).
Can you list what plugins you are using?
I’d also be curious if the non-logged in commenters have an email address (or something else) in the comment_author_email field in the wp_comments table. The warning stems from WordPress expecting the email variable in the code you posted to be a string, but it’s not. However, I can’t duplicate it locally, which I try to do so if it’s a bug with a theme or plugin, I (or you) can submit a bug report to the author.
I’ve tried the default themes and the error still occurs so it’s probably coming from the plugins. In the comments section on the dashboard, under author we have a name, email, ip address and image to the left of all that info for subscribed and unsubscribed users, the difference being unsubscribed users have the warning just before the name. Like I said, I do not know how to access the wp_comments database, perhaps I’m googling the wrong terms on how to learn it.
I will start on enabling and disabling the plugins for now. Here is a list of them:
Akismet Used by millions, Akismet is quite possibly the best way in the world to protect your blog from comment and trackback spam. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) Sign up for an Akismet API key, and 3) Go to your Akismet configuration page, and save your API key. Version 2.5.9 | By Automattic | Visit plugin site All In One SEO Pack Out-of-the-box SEO for your WordPress blog. Options configuration panel | Upgrade to Pro Version | Donate | Support | Amazon Wishlist Version 2.0.3.1 | By Michael Torbert | Visit plugin site All In One WP Security All round best WordPress security plugin! Version v2.6 | By Tips and Tricks HQ, Peter, Ruhul Amin | Visit plugin site Bad Behavior Deny automated spambots access to your PHP-based Web site. Version 2.2.14 | By Michael Hampton | Visit plugin site Captcha Plugin Captcha intended to prove that the visitor is a human being and not a spam robot. Plugin asks the visitor to answer a math question. Version 3.8.4 | By BestWebSoft | Visit plugin site | Settings | FAQ | Support Custom CSS Manager Edit Custom CSS to change the appearance of your WordPress Website Version 1.5.2 | By MyWebsiteAdvisor | Visit plugin site Easy Custom Auto Excerpt Auto Excerpt for your post on home, search and archive. Version 1.0.4 | By Todi Adiyatmo Wijoyo | Visit plugin site Email Users Allows the site editors to send an e-mail to the blog users. Credits to Catalin Ionescu who gave me (Vincent Pratt) some ideas for the plugin and has made a similar plugin. Bug reports and corrections by Cyril Crua, Pokey and Mike Walsh. Development for enhancements and bug fixes since version 4.1 primarily by Mike Walsh. Version 4.5.5 | By Mike Walsh & MarvinLabs | Visit plugin site Export Users to CSV Export Users data and metadata to a csv file. Version 0.3 | By PubPoet | Visit plugin site Floating Social Bar Floating Social Bar is the best social media plugin for WordPress that adds a floating bar with share buttons to your content without slowing down your site. Version 1.1.5 | By Syed Balkhi and Thomas Griffin | Visit plugin site Go Daddy Quick Setup Get your site started in ten minutes by answering some easy questions. Use our beautiful themes and popular plugin configurations to get your website started quickly. Version 1.04 | By GoDaddy.com, LLC | Visit plugin site | Leave feedback | Get support Google Doc Embedder Lets you embed MS Office, PDF, TIFF, and many other file types in a web page using the Google Docs Viewer (no Flash or PDF browser plug-ins required). Version 2.5.8 | By Kevin Davis | Visit plugin site Jetpack by WordPress.com Bring the power of the WordPress.com cloud to your self-hosted WordPress. Jetpack enables you to connect your blog to a WordPress.com account to use the powerful features normally only available to WordPress.com users. Version 2.5 | By Automattic | Visit plugin site Login Logo Drop a PNG file named login-logo.png into your wp-content directory. This simple plugin takes care of the rest, with zero configuration. Transparent backgrounds work best. Crop it tight, with a width of 312 pixels, for best results. Version 0.7 | By Mark Jaquith | Visit plugin site New User Email Setup A Plugin to setup the registration email sent to new users. REQUIRES PHP 5 Version 0.5.2 | By Alex Cragg | Visit plugin site Related Posts Quickly increase your readers' engagement with your posts by adding Related Posts in the footer of your content. Click on Related Posts tab to configure your settings. Version 2.8 | By Zemanta | Visit plugin site Safe Mode Makes it possible to enable safe mode for WordPress. In safe mode, plugins will not be loaded and the default theme (if installed) will be activated. Version 1.1 | By Uffe Fey, WordPress consultant Search by Google Google search on site widget Version 1.5 | By webvitaly | Visit plugin site | Support | Donate Social Comments This plugin adds Google Plus Comments , facebook comments, Disqus comments and the native comments system to your blog Version 0.1.2 | By Bainternet | Visit plugin site Social Widget A beautiful widget that allow you to add a stylish Facebook like box, twitter follow button and a google +1 button to your sidebar. Version 1.7 | By Ismail el korchi Tabbed Login Widget Easily add an beautifull tabbed login to your site's sidebar. Version 1.1.0 | By Vivek Marakana | Visit plugin site TablePress TablePress enables you to create and manage tables in your posts and pages, without having to write HTML code, and it adds valuable functions for your visitors. Version 1.1.1 | By Tobias B?thge | Visit plugin site | FAQ | Documentation | Support | Donate Theme Test Drive Safely test drive any theme while visitors are using the default one. Includes instant theme preview via thumbnail. Version 2.8.4 | By Vladimir Prelovac | Visit plugin site Tweet old post This plugin helps you to keeps your old posts alive by tweeting about them and driving more traffic to them from twitter. It also helps you to promote your content. You can set time and no of tweets to post to drive more traffic.For questions, comments, or feature requests, contact me! Ajay Matharu you can follow me twitter at @matharuajay. Version 4.0.7 | By Ajay Matharu | Visit plugin site User Profiles Made Easy An awesome user profiles plugin for WordPress. Version 1.4.1 | By ThemeFluent | Visit plugin site User Role Editor Change/add/delete WordPress user roles and capabilities. Version 4.5.2 | By Vladimir Garagulya | Visit plugin site | Changelog Welcome to WordPress Optimal configuration and additional help for your WordPress site. This was installed when your account was setup. Version 1.0 | By Starfield Technologies WordPress Importer Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file. Version 0.6.1 | By wordpressdotorg | Visit plugin site WordPress SEO The first true all-in-one SEO solution for WordPress, including on-page content analysis, XML sitemaps and much more. Version 1.4.18 | By Joost de Valk | Visit plugin site WP-Mail-SMTP Reconfigures the wp_mail() function to use SMTP instead of mail() and creates an options page to manage the settings. Version 0.9.1 | By Callum Macdonald | Visit plugin site WP Modal Login A highly configurable and versatile modal (pop-up) login form. Version 2.0.6 | By Cole Geissinger | Visit plugin site
Can you replicate the problem using the default Twenty Thirteen theme with all plugins deactivated?
The OP already did that using Safe Mode plugin and that eliminated the warning. Just changing the theme didn’t. So plugin issue.
Then the only way to find the culprit is to deactivate the lot and re-activate them one by one until s/he hits the problematic one.
I narrowed it down to the User Profiles Made Easy plugin so I deactivated it. Tested out most of the features it provides like username/email login and password definition during registration. It doesn’t seem like it was doing anything there.
Before deactivating it I played around with the settings and no dice. The plugin also has quite a number of files so I wouldn’t know where to begin searching for the root of the problem by code. I should add that I took over management of the site from someone else so I do not know what he used the plugin for.
If it stays okay deactivated I think I may leave it as is. Thank you very much for your responses.
Good deal. Ok, that’s a premium plugin, so you may get with the author and see if he can fix that for you.
- The topic ‘Formatting.php error’ is closed to new replies.