Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a WP plugin, where all admin setting field values were suddenly changed to the letter 'a'. All settings are stored in one 'big' option in the table. Seemed like the serialization gone wrong.

I run a var_dump on the get_option value and it returned a truncated string, not an array as usual. I'll update the question once I can reproduce the truncated string again.

I only use the 'Save changes' button and let the WP Options API write to the option, getting the values from user changeable or hidden HTML fields.

Is there any special characters or similar that can prevent an option from being written properly which could result in the serialized array being truncated?

The cause has something to to with Instagram or an Instagram user name.

share|improve this question
1  
Incompatible character encodings (ISO-8859-1 versus UTF-8) can result in truncated strings. But this happens usually in the first invalid byte, not as early as on the first letter. But check the encoding nevertheless. –  toscho Jun 23 '13 at 9:57
    
Did you check what is written to database? Is there a correct value for this options fields or is it saved incorrectly? –  Krzysiek Dróżdż Jun 23 '13 at 11:54
2  
Then write an answer with all the details please. And mark your question as answered. –  toscho Jun 23 '13 at 17:17
add comment

1 Answer

up vote 1 down vote accepted

It was a 👼 character. Make sure you sanitize everything that gets written as field values, even if it's a username.

trim(preg_replace("/[^\w\s]+/", "", $user->full_name))

I assumed there are no special characters in Instagram usernames. Never assume. I don't really use Instagram, just my plugin supports it. BTW it got truncated on the first occurrence of the special character.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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