Archive

Posts Tagged ‘subversion’

FIX: WordPress Older Posts not working in IIS with Permalinks

April 28th, 2010 2 comments

I spent some time tweaking my blog today after moving it to some fresh hardware. You may find that everything is loading much faster now which can be attributed to two plugins in addition to the hardware upgrade – wp-super-cache and wp-widget-cache.

I’ve also fixed a long standing bug with my particular configuration of WordPress that runs on IIS which causes the “Older posts” link at the bottom does not function for the second page. The WordPress generated URL for this is

http://www.thushanfernando.com/index.php/Index.php/page/2

Which is a bit problematic, this ofcourse can be reproduced only on IIS from my musings (serves me right eh?). There are a couple of suggestions by people on the forums already, but I wasn’t too keen on them as they seemed too high-level fixes.

I’ve enabled Permalinks with this format:

http://www.thushanfernando.com/index.php/2010/04/28/sample-post/

So I looked through the sources to see why this was happening. After a bit of snooping about I got to the get_pagenum_link function in wp-includes/link-template.php file.

Heres a bit of source for reference – this is with WordPress 2.9.2:

function get_pagenum_link($pagenum = 1) {
	global $wp_rewrite;

	$pagenum = (int) $pagenum;

	$request = remove_query_arg( 'paged' );

	$home_root = parse_url(get_option('home'));
	$home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
	$home_root = preg_quote( trailingslashit( $home_root ), '|' );

	$request = preg_replace('|^'. $home_root . '|', '', $request);
	$request = preg_replace('|^/+|', '', $request);

	if ( !$wp_rewrite->using_permalinks() || is_admin() ) {
		$base = trailingslashit( get_bloginfo( 'home' ) );

		if ( $pagenum > 1 ) {
			$result = add_query_arg( 'paged', $pagenum, $base . $request );
		} else {
			$result = $base . $request;
		}
	} else {
		$qs_regex = '|\?.*?$|';
		preg_match( $qs_regex, $request, $qs_match );

		if ( !empty( $qs_match[0] ) ) {
			$query_string = $qs_match[0];
			$request = preg_replace( $qs_regex, '', $request );
		} else {
			$query_string = '';
		}

		$request = preg_replace( '|page/\d+/?$|', '', $request);
		$request = preg_replace( '|^index\.php|', '', $request);
		$request = ltrim($request, '/');

		$base = trailingslashit( get_bloginfo( 'url' ) );

	if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) )
		$base .= 'index.php/';

		if ( $pagenum > 1 ) {
			$request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' );
		}

		$result = $base . $request . $query_string;
	}

	$result = apply_filters('get_pagenum_link', $result);

	return $result;
}

This function (from reading through) essentially generates the links for the page numbers & page navigation taking into account Permalinks if configured. This is all fine and dandy for Unix hosts but for Windows, unfortunately this bit of code fails us.

...
$request = preg_replace( '|page/\d+/?$|', '', $request);
$request = preg_replace( '|^index\.php|', '', $request);
$request = ltrim($request, '/');
...

As the preg_replace is case sensitive, it will not replace the invalid Index.php that is seen on IIS. So the easiest fix is to tweak the regex pattern a little bit and tell it be case insensitive.

...
$request = preg_replace( '|page/\d+/?$|', '', $request);
$request = preg_replace( '/|^index\.php|/i', '', $request);
$request = ltrim($request, '/');
...

This will then generate the (invalid) urls and the preg_replace will remove any additional Index.php’s from the request URL as its already mentioned in the $base variable a few lines below:

...
if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) )
$base .= 'index.php/';
...

Once you make the change and upload the files, your “Older posts” will start working again. I’ll submit a patch to WordPress I’ve submitted a patch to WordPress Trac, now its just a wait and see what they say, in the meantime here’s a patch file if you don’t want to modify sources manually. If there any issues, post a comment 🙂

{lang: 'en-GB'}
Share

TortoiseSVN 1.6.1 Released

April 13th, 2009 No comments

TortoiseSVN 1.6.1 is out with several changes & fixes linked with Subversion 1.6.1.

Download:

Whilst on the subject of all things Subversion, have you seen the Subversion v1.6 Quick Reference Card? Enjoy. Waiting for a VisualSVN 1.7.1 update anytime soon.

{lang: 'en-GB'}
Share

Sweet Ride: TortoiseSVN 1.6 Released!

March 23rd, 2009 No comments

Just realised that TortoiseSVN 1.6 has made it into the open!

Culminating over 9 months of development effort, this is the best release of TortoiseSVN yet, linked against Subversion 1.6.0. It delivers a lot of new features, including:

  • improved revision graph
  • improved log cache
  • many UI enhancements
  • Early support for tree conflict detection
  • …and many more.

You can get this latest release from our download page.

Please don’t forget to first read the release notes!

Together with this release, new versions of the CommitMonitor and the SVNProtocolHandler are also available.

Yay! Update for VisualSVN should be out any day now.

{lang: 'en-GB'}
Share

Subversion Global Ignore List

June 29th, 2008 2 comments

I’ve been using TortoiseSVN as my Subversion client for a while now (and TortoiseCVS for CVS) but one thing I love about the client is the global ignore filtering. Having to install TortoiseSVN on a new box today I figured I’d post this for reference, its been tweaked over the years but it covers everything I need to ignore.

*.resharperoptions Web_Data log */[Bb]in [Bb]in */obj obj */[Rr]elease */[Dd]ebug *.user *.suo *.resharper */_ReSharper.* _ReSharper.* *.bak *.dll *.pdb. *.class *.exe *.old *.scc *.vspscc *.bak *.vsp *.ncb *.aps */.int */_UpgradeReport* UpgradeLog*.XML
Updated – 16/07/2008
Thanks to my good buddy Edwin Vermeer to include the TestResults Pruning and Setup Projects output folders….
*.resharperoptions Web_Data log */[Bb]in [Bb]in */obj obj */TestResults
TestResults */[Rr]elease [Rr]elease */[Dd]ebug [Dd]ebug *.user *.suo
*.resharper */_ReSharper.* _ReSharper.* *.bak *.dll *.pdb. *.class *.exe
*.old *.scc *.vspscc *.bak *.vsp *.ncb *.aps */.int */_UpgradeReport*
UpgradeLog*.XML

Set the global options by right clicking on any folder, goto Settings in the TortoiseSVN context menu and under the General settings pane enter the above into the ‘Global ignore pattern:‘ textbox.

{lang: 'en-GB'}
Share