tedster - 4:35 am on Feb 3, 2013 (gmt 0)
I don't know the PHP code (sorry) but I do want to point out that the canonical tag you traditionally used is an error.
The href attribute should NOT be the domain name in every case. Instead is should be the on intended URL for the actual content of that unique page. The only page that would use the canonical tag as you've written it would be the home page.