It has been brought to my attention that there is currently a small bug in Wordpress 2.7.1 that affects certain users of my Status Press Widget and Customizable Search Widget.
This bug mainly affects users of PHP4, because the htmlspecialchars_decode function is not included until PHP5, so Wordpress has now integrated a simulation of the same function in the code core of 2.7.
If you are a PHP4 user running Wordpress 2.7.1, you may get this error from a plugin or widget that attempts to access the htmlspecialchars_decode function:
Warning: htmlspecialchars_decode() expects parameter 1 to be string, NULL given in /home/myname/public_html/personal/wp-includes/compat.php on line 105:
PHP5 users already have this function inherint in their repository, so it just bypasses the Wordpress simulation function.
Apparently when 2.7.1 was released, a slight oversight caused the function to be looking for a variable that was not being passed to it because of a misnaming error.
Details about this error are located in the Wordpress bug tracking system, and it looks like a fix has been submitted for the next version.
However, what should I do until the update? I did some looking into the code that is affected, and noticed that basically in the htmlspecialchars_decode function, Wordpress passes the two expected variables (the string, and the quote style) to its own parser called wp_specialchars_decode. Instead of relying on the PHP version, I have updated my plugins to directly call the Wordpress version of the function to ensure compatibility. Scratch that, that’s not going to work. The wp_specialchars_decode function is only included in Wordpress as of 2.7.1, so it is not backwards compatible and not wise to use.
Instead, you should go ahead and fix the problem with the core file if you are using 2.7.1 and PHP4.
- Open up /public_html/<WP Directory>/wp-includes/compat.php
- Scroll down to line 104: if ( !is_scalar( $string ) ) {
- Change $string to $str
- Do the same thing for the line below it, 105.
- Save the file back to your server
- Update your plugins.
When you have followed these steps, you should be good to go. If you do not feel comfortable editing the file yourself, you can just download my edited copy of compat.php:
compat.php (3.4 KiB, 176 hits)
You need to be a registered user to download this file.
Be sure to upload it to the wp-includes directory. Then update the plugins and widgets that have become broken.
You can find the updates to my widgets here:
If you have any questions or concerns, please do not hesitate to let me know. Oh, and if this has helped you, don’t forget to show a little love: