Remove unnecessary cast to float from comment_ranking()
» Remove unnecessary cast to float from comment_ranking() and statistics_ranking()
I am not sure whether it was necessary or not, but as discussed on the other issue, it replaced a cast that was in the SQL, which wasn't working for me in MySQL:
On that other issue, I just wanted to get the rankings working, so I left the cast in there to reproduce what had previously been happening.
And as a note, if we change this, we should also remove it from statistics_ranking(), which does a very similar cast for the same reason (replacing a very similar SQL cast).
Note that the diff in #2 changes behavior slightly as the 0 in the ternary is no longer casted to float. I don't think that makes any difference (especially because of the multiplication with 0) but wanted to note that for completeness sake. The reasonis that in PHP type-casting precedes over the ternary operator.
I'm looking into this in PostgreSQL in conjunction with #2195907: Search ranking for number of views fails in PostgreSQL, which appears to be related to this. So far it looks like the comment module ranking works OK without the float cast, but the statistics module ranking doesn't. I cannot fathom why that would be, because they have nearly identical code except that one uses the comment_entity_statistics table and the other uses the node_counter table. But if I can fix the statistics one by casting in the cron call, I'll do the same for the comment (just in case).
Comments
Comment #1
andypostProbably this needed for postgresql
Comment #2
jhodgdonI am not sure whether it was necessary or not, but as discussed on the other issue, it replaced a cast that was in the SQL, which wasn't working for me in MySQL:
On that other issue, I just wanted to get the rankings working, so I left the cast in there to reproduce what had previously been happening.
And as a note, if we change this, we should also remove it from statistics_ranking(), which does a very similar cast for the same reason (replacing a very similar SQL cast).
Comment #3
tstoecklerNote that the diff in #2 changes behavior slightly as the 0 in the ternary is no longer casted to float. I don't think that makes any difference (especially because of the multiplication with 0) but wanted to note that for completeness sake. The reasonis that in PHP type-casting precedes over the ternary operator.
Comment #4
jhodgdonI'm looking into this in PostgreSQL in conjunction with #2195907: Search ranking for number of views fails in PostgreSQL, which appears to be related to this. So far it looks like the comment module ranking works OK without the float cast, but the statistics module ranking doesn't. I cannot fathom why that would be, because they have nearly identical code except that one uses the comment_entity_statistics table and the other uses the node_counter table. But if I can fix the statistics one by casting in the cron call, I'll do the same for the comment (just in case).
Comment #5
jhodgdonIt turns out that the SQL CAST is needed for PostgreSQL, and the (float) is not helping anything, so I'm addressing this on #2195907: Search ranking for number of views fails in PostgreSQL. Closing this one as a duplicate accordingly.