Upgrading Mint for use with PHP 7+
This is a very niche post, but I’m posting it mainly to help people who might be searching Google for the solution to this problem: if you have been using Shaun Inman’s Mint for self-hosted website stats, you may have noticed that it no long works in PHP 7 and above.
When I noticed it broke, I spent several hours trying to figure out why and to fix it as quickly and easily as possible. Essentially, there are two reasons why it doesn’t work anymore:
- PHP 7 no longer lets you use
"=&"to “assign a new object by reference”. I don’t even really know what this means, but I do know you can solve it simply by removing the
&. There is only one place you need to do this in Mint’s code and that is on line 3409 of
/mint/app/lib/mint.phpwhere it says
$DOM =& new SI_Dom($xml);. This problem was infuriating because it just makes the whole app fail silently, without throwing a single error. I spent a half a day deleting random code just to identify the culprit.
- The MySQL API has been deprecated in PHP 7 and Mint uses it for all of its database work. You’re supposed to rewrite all of your queries to use the new
PDO_MySQLAPIs, but after a few hours of trying to do this, I realized my PHP skills were not up to the task and I opted for an easier solution instead. There’s a wrapper you can just include with your Mint install that translates all of the functions on the fly for you. This method is generally “not recommended” by people who actually know what they’re doing, but for a quick fix, it worked perfectly for me. If someone wants to patch Mint correctly, I will gladly post a pointer to it here. Anyway, all you have to do is download that file, upload it to
path.php), call it something like
mysql_bridge.phpand then add this line right above the first
Voila! You’re done. The whole procedure should take only a few minutes.