Archive | January, 2017

PHP is_numeric () fails WordPress version string check

This is, perhaps, obvious to most PHP developers. But it came somewhat as a surprise to me.

Using is_numeric () for validating a WordPress version string, such as ‘4.7’, does not seem to work very well when WordPress introduces minor releases such as ‘4.7.1’.

Since I cannot be bothered to figure out why it behaves in this (erratic, IMHO) way, I have since replaced the call to is_numeric () with a small function using a simple regular expression (regexp):

    function wpVersionStringCheck ($vs)                                                                                                 
        return (preg_match ('/^(\d+\.)+\d+$/', $vs));                                                                                   

I’m sure there is a hole in there somewhere, but on the following strings at least, it gives me the desired result:

1.0 is valid
1.0. is invalid
1.0.1 is valid
1.banana.0 is invalid


ttf-mscorefonts-installer and Ubuntu 16

As has been confirmed in a number of posts on the Internet, there’s a problem with the ttf-mscorefonts-installer package on Ubuntu 16.

There are a number of solutions, and as odd as it might sound, solutions that work for some will fail for others.

I had to mix a number of suggested solutions to get it working on Ubuntu 16.04.LTS. This is what worked for me, your mileage may vary:

sudo rm -rf /var/lib/update-notifier/package-data-downloads/partial/*
sudo dpkg -P ttf-mscorefonts-installer

After which I went to this page to get an updated version of the ttf-mscorefonts-installer:

And from the directory to where you downloaded the .deb file to:

sudo dpkg --install ttf-mscorefonts-installer_3.6_all.deb

Good luck!


Powered by WordPress. Designed by WooThemes