0

It's for two or three months that this problem exists in WordPress multisite and I'm still waiting for a solution or an update.

When adding new site, I get this error:

Warning: preg_match() expects parameter 2 to be string, object given in /home/metavarz/public_html/m-v/wp-includes/formatting.php on line 3435

Warning: preg_match() expects parameter 2 to be string, object given in /home/metavarz/public_html/m-v/wp-includes/formatting.php on line 3424

Warning: preg_match() expects parameter 2 to be string, object given in /home/metavarz/public_html/m-v/wp-includes/formatting.php on line 3435

Warning: strip_tags() expects parameter 1 to be string, object given in /home/metavarz/public_html/m-v/wp-includes/formatting.php on line 3407

Warning: strip_tags() expects parameter 1 to be string, object given in /home/metavarz/public_html/m-v/wp-includes/formatting.php on line 3407

Catchable fatal error: Object of class WP_Error could not be converted to string in /home/metavarz/public_html/m-v/wp-includes/kses.php on line 1038

Have anybody found a safe solution for this without making any threat to the database?

I've already found some suggestions on this post. They say we should change the value of:

define('DB_COLLATE', '');

to:

define('DB_COLLATE', 'utf8mb4_general_ci');

Is it safe for our website?

We have lots of posts on our website and we don't want to make any problem for our database and website.

0

The problem was solved in the next update of WordPress. By the way if you still haven't updated your version of WordPress:

It's enough to set DB_COLLATE in the wp-config.php:

define('DB_COLLATE', 'utf8mb4_general_ci'); // on condition that your DB_CHARSET is 'utf8mb4'

That's it!

The bug is hidden in the file \wp-includes\wp-db.php on the line 731 in the function init_charset(). For multisite mode the 'utf8_general_ci' collation is used if DB_COLLATE is empty. And if your DB_CHARSET is 'utf8mb4' then the error occures.

The actual error is raised when creating and consequently querying nonexistent tables for the new site ('2' changes with the number of sites):

wp_2_terms

wp_2_term_taxonomy

wp_2_term_relationships

wp_2_commentmeta

wp_2_comments

wp_2_links

wp_2_options

wp_2_postmeta

wp_2_posts

someone suggested this solution and it works fine.

  • While the link might answer the question, you should include the essential parts of the answer here and only provide the link for reference. Link-only answers can become invalid if the linked page changes. – Gabriel Jan 6 '16 at 14:59
  • Yes, you're right. I added the details. Thanks for reminding. – Milad Nasri Jan 6 '16 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.