Re: [1.0.10] Total karma mode broken on PHP 7.0/7.1
Reply #3 –
Well this was not what I thought it would be.
I thought this would be some cast problem, where we passing a string or null value and expected PHP to auto cast when the "math" was done. But after ensuring that ints were being passed to the template the error persisted. In doing some testing, its actually a template error, at least in php 7.x
In GenericMessages.template.php
<li class="listlevel2 karma">' . $modSettings['karmaLabel'] . ' ' . $message['member']['karma']['good'] - $message['member']['karma']['bad'];
<li class="listlevel2 karma">' . $modSettings['karmaLabel'] . ' ' . ($message['member']['karma']['good'] - $message['member']['karma']['bad']);
Wrapping the match in ()'s seems to fix the problem. Looks like php7 has done some optimization on echo concatenation, as such by the time it gets to the minus sign, its using the entire left side which is a concatenated string, so it attempts to eval "Karma 2 - 1" or some such thing. Anyway the ()'s should ensure the correct order of things, so give it a try.