Over the last 12 hours I have been trying to do something with dates in WordPress/PHP. It feels like a shell game. When is a date not a date?

Was just reviewing commit comments to find when I made a change. It was taking ages. Then I remembered I have changelogs ?

Anyone else worry when the WordPress Comment spam is empty? It should feel like success but it never does.

So, I had a minor disaster. This is what went wrong and how I fixed it.

We use the amazing WordPress Redirection plugin. We recently started a survey and the best way to contact the participants was by letter. We had to include a URL to the survey. Some people were mistyping the URL. For example:

/direct-payments-servey
/direct-payments-urvey
/directpayment-survery/
/directpaymentsurvey
/directpaymentssurvey

The correct URL is /direct-payments-survey/

To fix this, at 8:10am this morning, I threw up a very hasty regex redirect and went to have my breakfast, slapping myself on the back. It matches all the errors and, I thought, would catch most other typos. Here it is:

^/(directpayment|direct-payment).*

Problem is it also caught the target URL and an endless redirect ensued. The page was down for 9 hours.

After my trials a little while back trying to get to grips with not matching strings in a regex I had a good idea for how to fix it.

^/(?!direct-payments-survey)(directpayment|direct-payment).*

It was that easy. Here is the regex on regex101 as usual.

The silver lining here is that I now have a very reusable fix when I need to match something very close to the target URL. I’ve had this problem in the past and often just created a completely different URL. Even then this was not foolproof as WordPress keeps it’s own records of old URLs and redirects.

I do like celebrate a victory but today I must acknowledge a failure. I put a pretty important web page into an endless redirect loop with some fast and loose admin. Sadly, I made that change at 8:10am and I only just fixed it… ?

I use Chrome once a month at work to access analytics from the major social media platforms at it almost always breaks. How is this the world’s most popular browser?