My First WordPress Bug

Album Cover: Life in 1472

"Even with a patch on my eye, I'm dreamy."
Slick Rick / Fresh

Posted on January 10, 2008 12:01 AM in Web Development
Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

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]; 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.


manual Blog commenting on September 08, 2016 at 4:11 AM:

Much obliged for this incredible post, i discover it exceptionally fascinating and extremely well thoroughly considered and set up together. I anticipate perusing your work later on.


تركيبات on April 07, 2017 at 9:36 AM:

I have a mission that Iím just now working on, and I have been at the look out for such information.


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.


Email Address:



Check this box if you hate spam.