On PHP 7.1 with enabled total karma user profile in post show only negative karma points.
PHP 7.0 has the same issue but error log is empty. In both cases Karma label set in settings is not displayed in topic view.
Karma count and label on action?profile is correct.
With enabled karma positive/negative label is visible in topic view, so maybe it's only related to Total Karma mode.
This version: ElkArte 1.0.10 (more detailed)
Current version: 1.0.10
GD version: bundled (2.1.0 compatible)
MySQL version: 10.1.21-MariaDB-cll-lve
Zend OPcache: 7.1.3
PHP: 7.1.3 (litespeed) (more detailed)
Server version: LiteSpeed
I just installed 7.1 on one of my sites so will be able to check soon
maybe it was even before 1.0.10, but only yesterday I moved my sites to new host where I can choose PHP versions
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.
Regardless of how PHP treats it, I think it's much clearer what's going on in the replacement. :)
seems to work good now :)
In find/replace code is a typo, so if anyone will copy/paste code it can break template, corrected replacement:
<li class="listlevel2 karma">' . $modSettings['karmaLabel'] . ' ' . $message['member']['karma']['good'] - $message['member']['karma']['bad'] . '</li>';
<li class="listlevel2 karma">' . $modSettings['karmaLabel'] . ' ' . ($message['member']['karma']['good'] - $message['member']['karma']['bad']) . '</li>';
/me thinks we should do an str_replace. :P
<li class="listlevel2 karma">' . str_replace('{karma_total}', ($message['member']['karma']['good'] - $message['member']['karma']['bad']), $modSettings['karmaLabel']);
@emanuele - also missing closing </li> :)
Yep, I think it may make sense.
But it may also be overkill, who knows. xD
Is that a 1.1 bug as well?
sorry for the off-topic but with Likes enabled do we really need the Karma function? I have to admit I never used the Karma system
Karma and likes are two different things: one targets the user, one the content.
I never used it myself, but considering the amount of code involved it doesn't really make much difference to have it or not in terms of maintenance.