WordPress 4.3 “Billie” is out

The brand new and shiny version 4.3 of WordPress is out, bringing more bells and whistles to Customizer, formatting shortcuts to the editor (looks like Markdown made its mark), and more.

I’ve upgraded and also switched this site to Twenty Fifteen theme, just to see how it all works.  No coding customization done yet – only whatever is available through the mouse clicks.

How to Choose the Right Domain Name

First Site Guide runs a good article on how to choose the right domain name.  I mostly agree with it, except for maybe this part:

No numbers or hyphens
Numbers and hyphens (especially hyphens) cause confusion. Stay away from them at all costs. Even something as clever as the number1website.com will cause confusion. Make the name speak for itself.

Especially the part about hyphens.  Ideally, I’d say you should use a single word domain.  But if you do have two or more words, use hyphens.  Hyphens act as separators, much like spaces, and make your domain more readable.  Have a look at these domains and imagine them hyphened – that’d be a totally different story, don’t you think?

PHP session encoding

I’ve been coding PHP for a few years now, but still once in a while I come across something that I had no idea about.  In a recent project I was working on the single sign on (SSO) integration with the customer’s internal systems.  After doing the initial proof of concept code snippet, I got the logged in user results from a shared caching server.  The string looked something like this:

UserAuth|a:2:{s:8:"username";s:6:"leonid";s:4:"role";s:5:"admin";}UserSettings|a:2:{s:8:"language";s:2:"en";s:8:"timezone";s:5:"GMT+2";}

This was very similar to the results of PHP’s serialize() function, but not quite.  I’ve asked around, but nobody could point me in the right direction, so I went the regular expression way to parse this (do I have two problems now?).

After a code review and discussion with the developers on the customer side, I’ve learned that this is apparently a result of PHP’s session_encode() function, which I haven’t seen in the wild until that day.  Excellent! Now I should be able to use session_decode() to parse that, right?  Well, almost.  According to PHP Sadness #29:

The only way to decode php-session-format serialization (different from normal php serialize) is by calling php session_decode, which can only be called if there is an active session. If there is no active session, you can’t decode session data without starting one first.

So, don’t forget to session_start() before you try to decode.  Which makes it a bit tricky if you already have a session that you don’t want to ruin.  You might want to look into session_name() to work around it.  Gladly, I didn’t have to resolve to that as another customer-specific work around was implemented.