I was browsing through the functions.php file that comes with WordPress 2.3.2 tonight, and I spotted this function:
function xmlrpc_getposttitle($content) {
global $post_default_title;
if ( preg_match('/<title>(.+?)</title>/is', $content, $matchtitle) ) {
$post_title = $matchtitle[0];
$post_title = preg_replace('/<title>/si', '', $post_title);
$post_title = preg_replace('/</title>/si', '', $post_title);
} else {
$post_title = $post_default_title;
}
return $post_title;
}
The two calls to preg_replace() immediately stood out, and upon closer inspection I realized that they are completely unnecessary.
Since preg_match(), which is called as part of the containing if statement, will store "the text that matched the first captured parenthesized subpattern" in $matchtitle[1], the two calls to preg_replace() can be removed completely as long as the following line:
$post_title = $matchtitle[0];
...is changed to:
$post_title = $matchtitle[1];
I just created a simplified test case and verified it, so I followed that up with a WordPress bug. I guess we'll see what happens.
Comments
No one has added any comments.
Post Comments
If you feel like commenting on the above item, use the form below. Your email address will be used for personal contact reasons only, and will not be shown on this website.