fix

WordPress MU/MS Empty Header and Broken Image Bug Fixed

I just switched to a new server and found myself struggling with empty HTTP headers and broken or partial images. The problem is the memcache extension for PHP and WordPress MU/WordPress multisite’s need to reinstantiate the wp-cache after determining the correct blog for a given request.

Versions of the memcache extension prior to 3.0 go wrong somehow and it shows up when you try to do an HTTP HEAD request on a page (the result is empty) or enable X-SendFile support for WP MU/MS’ file handling (all the files and images in the media library will break). Upgrading to the the 3.x version (in beta since 2007) fixes the problem.

You may have to uninstall the old version before installing the beta, and installing the beta via PECL requires adding “-beta” to the package name. Here are the commands:

pecl uninstall memcache
pecl install memcache-beta

Improving Will Norris’ Open Graph Plugin

Will Norris put together a nice WordPress plugin to place Open Graph metadata on the page. Today I patched it to address a few bugs I and others have found.

The patch switches functions that depended on globalizing $post to use $wp_query->queried_object and similar.

opengraph_default_url() is changed to try get_permalink() only when is_singlular() is true. Otherwise it uses the blog’s base URL. This isn’t perfect, but it’s better than having the front page and all tag/category/archive pages report their og:url as being the permalink for the first post on the page.

As suggested here, I changed the opengraph_default_description() to use the post’s excerpt if is_singular() and the post includes an excerpt.

I changed opengraph_default_image() to test if the theme supports post thumbnails before calling has_post_thumbnail() to avoid the Fatal error: Call to undefined function has_post_thumbnail() errors.

I submitted it as a bug report in the plugins Trac, but I don’t check there for tickets on my own plugins, so you might apply the patch yourself.

Fixing Batcache to Send The Correct Content-Type Header

I’m a fan of Batcache, the Memcached-based WordPress full-page cache solution, but I’ve discovered that it ignores the content-type header set when the page is initially generated and re-sends all content with content-type: text/html. I posted a note about this at the WordPress support forums, but then I realized what the problem was: apache_response_headers() doesn’t return the content type, but headers_list() does.

The solution is to replace apache_response_headers() with headers_list() in the code, though headers_list() is PHP 5+ only, so it might be a while before we see a change like this committed. Still, I’ll shamelessly tag Andy Skelton (Batcache’s author) on it.

Many Eyes, Bugs Being Shallow, All That

WordPress 2.5.1 added a really powerful feature to register_taxonomy(): automatic registration of permalinks and query vars to match the taxonomy. Well, theoretically it added that feature. It wasn’t working in practice. After some searching yesterday and today, I finally found the bug and worked up a fix. I made a diff and set off to […] » about 200 words

WordPress Strips Classnames, And How To Fix It

WordPress 2.0 introduced some sophisticated HTML inspecting and de-linting courtesy of kses. kses is an HTML/XHTML filter written in PHP. It removes all unwanted HTML elements and attributes, and it also does several checks on attribute values. kses can be used to avoid Cross-Site Scripting (XSS), Buffer Overflows and Denial of Service attacks. It’s a […] » about 300 words

bsuite Bug Fixes (release b2v7)

Contentsbsuite FeaturesFixed/Changed/AddedInstallationUpgradingCommandsClear bsuite_speedcacheRebuild bsuite tag indexOptionsMinimum userlevel to view bsuite reportsOutput default CSSDefault pulse graph styleSuggest related entries in postTag input formatHighlight search words and offer search helpFilter incoming search terms using comment moderation and blacklist wordsIgnore hits from registered users at or above userlevelIgnore hits from these IP numbersTag SupportUsing bsuite FunctionsKnown BugsMoney GrubbingWork […] » about 800 words

Displaying Google Calendars in PHP iCal

PHP iCalendar solves a couple problems I’m working on, but I needed a solution to fix the duration display for Gcal-managed ICS calendars.

As it turns out, a fix can be found in the forums, and the trick is to insert the following code in functions/ical_parser.php.


case 'DURATION':
	if (($first_duration == TRUE) && (!stristr($field, '=DURATION'))) {
		ereg ('^P([0-9]{1,2}[W])?([0-9]{1,2}[D])?([T]{0,1})?([0-9]{1,2}[H])?([0-9]{1,2}[M])?([0-9]{1,}[S])?', $data, $duration); 
	
		$weeks = str_replace('W', '', $duration[1]);
		$days = str_replace('D', '', $duration[2]);
		$hours = str_replace('H', '', $duration[4]);
		$minutes = str_replace('M', '', $duration[5]);
		$seconds = str_replace('S', '', $duration[6]);
		
		// Convert seconds to hours, minutes, and seconds
		if ($seconds > 60) {
			$rem_seconds = $seconds % 60;
			$minutes = $minutes + (($seconds - $rem_seconds) / 60);
			$seconds = $rem_seconds;
		}
		if ($minutes > 60) {
			$rem_minutes = $minutes % 60;
			$hours = $hours + (($minutes - $rem_minutes) / 60);
			$minutes = $rem_minutes;
		}
		
		$the_duration = ($weeks * 60 * 60 * 24 * 7) + ($days * 60 * 60 * 24) + ($hours * 60 * 60) + ($minutes * 60) + ($seconds);
		$first_duration = FALSE;
	}
	break;

Hopefully this gets worked into the baseline with the next release.

bsuite Bug Fixes (release b2v6)

Contentsbsuite FeaturesFixed/Changed/AddedInstallationUpgradingCommandsOptionsTag SupportUsing bsuite FunctionsKnown BugsUpdate: bugfix release b2v7 available. It’s been a while since I released a new version of bsuite, my multi-purpose WordPress plugin. I’d been hoping to finish up a series of new features, but those have been delayed and this is mostly just a collection of bugfixes. This update is recommended […] » about 500 words

bsuite Bug Fixes (release b2v3)

ContentsFixedInstallationbsuite FeaturesI’ve fixed another bug in bsuite b2, my multi-purpose plugin. This update is recommended for all bsuite users. Fixed Previous versions would throw errors at the bottom of the page when the http referrer info included search words from a recognized search engine.  Installation Follow the directions for the bsuite b2 release. The download […] » about 300 words

bsuite Bug Fixes (release b2b)

ContentsFixesInstallationbsuite FeaturesI’ve fixed a couple bugs in bsuite b2, released last week. Fixes A bug with search word highlighting that caused it to litter the display in some cases.  A silly mistake of mine that cause a mysql error for some users. Installation Follow the directions for the bsuite b2 release. The download link there […] » about 300 words