Romain / Matomo-IP-to-Company

A plugin for Matomo which gives you the name of the company that visited your website, based on its IP.
GNU General Public License v3.0
15 stars 11 forks source link

Fixing bug in isPHPVersionMoreRecentThan #31

Open BenFunnelFuel opened 1 year ago

BenFunnelFuel commented 1 year ago

If the installed version is 8.1, and the function is called with the string 7.4, it should return true because 8.1 is more recent than 7.4. however it returns false, because the first conditional check fails, so we fall through to the second conditional (the elseif).

The problem with this second conditional is that it only examines the minor version, not taking into account the major version. So in our example, it compares 1 to 4. Since 1 is less than 4, this condition succeeds, and the function returns false.

This fix also simplifies the function by using a native PHP method that is purpose built for this use case