{"id":29425,"date":"2020-12-28T11:36:10","date_gmt":"2020-12-28T19:36:10","guid":{"rendered":"https:\/\/mikeindustries.com\/blog\/?p=29425"},"modified":"2020-12-29T11:41:13","modified_gmt":"2020-12-29T19:41:13","slug":"upgrading-mint-for-use-with-php-7","status":"publish","type":"post","link":"https:\/\/mikeindustries.com\/blog\/archive\/2020\/12\/upgrading-mint-for-use-with-php-7","title":{"rendered":"Upgrading Mint for use with PHP 7+"},"content":{"rendered":"<p>This is a <em>very<\/em> niche post, but I&#8217;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&#8217;s <a href=\"https:\/\/haveamint.com\">Mint<\/a> for self-hosted website stats, you may have noticed that it no long works in PHP 7 and above.<\/p>\n<p>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&#8217;t work anymore:<\/p>\n<ol>\n<li>PHP 7 no longer lets you use <code>\"=&\"<\/code> to <a href=\"https:\/\/www.php.net\/manual\/en\/migration70.incompatible.php\">&#8220;assign a new object by reference&#8221;<\/a>. I don&#8217;t even really know what this means, but I do know you can solve it simply by removing the <code>&<\/code>. There is only one place you need to do this in Mint&#8217;s code and that is on line 3409 of <code>\/mint\/app\/lib\/mint.php<\/code> where it says <code>$DOM =& new SI_Dom($xml);<\/code>. 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.<\/li>\n<li>The MySQL API has been deprecated in PHP 7 and Mint uses it for all of its database work. You&#8217;re supposed to rewrite all of your queries to use the new <code>mysqli<\/code> or <code>PDO_MySQL<\/code> APIs, 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&#8217;s a <a href=\"https:\/\/github.com\/e-sites\/php-mysql-mysqli-wrapper\">wrapper<\/a> you can just include with your Mint install that translates all of the functions on the fly for you. This method is generally &#8220;not recommended&#8221; by people who actually know what they&#8217;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 <code>\/mint\/app\/<\/code> (next to <code>path.php<\/code>), call it something like <code>mysql_bridge.php<\/code> and then add this line right above the first <code>include<\/code> statement in <code>\/mint\/index.php<\/code>: <code>include(MINT_ROOT.'app\/mysql_bridge.php');<\/code><\/li>\n<\/ol>\n<p>Voila! You&#8217;re done. The whole procedure should take only a few minutes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a very niche post, but I&#8217;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&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":29429,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,282],"tags":[510],"class_list":["post-29425","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code","category-original","tag-rgb-155-163-76"],"_links":{"self":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/posts\/29425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/comments?post=29425"}],"version-history":[{"count":4,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/posts\/29425\/revisions"}],"predecessor-version":[{"id":29430,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/posts\/29425\/revisions\/29430"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/media\/29429"}],"wp:attachment":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/media?parent=29425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/categories?post=29425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/tags?post=29425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}