Upgrade to WordPress 2.8 didn’t go as expected
June 23, 2009Much to my amazement the upgrade of WordPress 2.7 to WordPress 2.8 didn’t quite go as expected on my blog. Somehow after the upgrade all content of my posts, pages and comments on the output of my blog just disappeared into thin air.
The first thing I did was checking the database and I was relieved to see the content was actually still there. Then the debugging session began: deactivating all plugins and switching back to the default template showed no improvement. Hence, the conclusion it was not template or plugin related.
So there has to be something else happing with the core files. After some more debugging, with the help of the WordPress IRC channel, I found out which filter was responsible for the disappearance of my content, a WP filter called: convert_smilies. The obvious step to show the content again is to remove the filter in question by adding the following lines to your wp-config.php:
remove_filter('the_content', 'convert_smilies');
remove_filter('the_excerpt', 'convert_smilies');
remove_filter('comment_text', 'convert_smilies');
At least this will show the textual output again, but smilies are not translated to images. While I’m still debuging the issue I’ll continue to post my findings in this post.
Further analysis and subsequent var_dumps revealed the most likely source of the problem. Between WP 2.7.1 and WP 2.8.x the replacement of the smileys has been rewritten to use preg_replace_callback instead of preg_replace. The offending line, which isn’t working on my setup is the line where the actual replacement of textual smileys to graphics take place:
$content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
The variable $content is NULL after that particular call.
So I turned on the WP_DEBUG variable by adding the following statement to the wp-config.php file:
define ('WP_DEBUG',true);
After reviewing the page again I was greeted with a warning regarding the offending code of the preg_replace_callback:
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier ‘|’ in /wp-includes/formatting.php on line 1347
This warning, although I don’t have a solution yet, is most likely the cause of the empty content variable.
UPDATE: Problem solved
Some of the smileys in the $wpsmiliestrans array configured in the wp-config file did actually work while others were not. Thanks to some pointers from Jay and the help from some developers on IRC we managed to track the problem down.
It all has to do with escaping certain characters before entering them into a regular expression. WordPress uses the function preg_quote for this. As stated in the manual the special regular expression characters are: . \ + * ? [ ^ ] $ ( ) { } = ! < > | :. As you can see a very nice list, not including /, which in my case is a delimiter that does needs to be escaped.
So if we look at the code of preg_quote and tell the function to escape ‘/’ as well, all is fine. Anyway, the issue has been fixed in the nightly builds of WP.
















The best information i have found exactly here. Keep going
LnddMiles | July 21, 2009The best information i have found exactly here. Keep going Thank you