seriesreviews.php: rate-only submissions count toward the series rating (fixes #11)
| ... | ... |
@@ -55,7 +55,12 @@ $newcount = dbquery("SELECT count(reviewid) as totalcount FROM ".TABLEPREFIX."fa
|
| 55 | 55 |
(count($serieslist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $serieslist))."') > 0 AND type = 'SE')" : "").
|
| 56 | 56 |
") AND review != 'No Review'"); |
| 57 | 57 |
list($totalcount) = dbrow($newcount); |
| 58 |
-if($totalcount) $update = dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET rating = '".round($totalreviews ?? 0)."', reviews = '$totalcount' WHERE seriesid = '$thisseries'");
|
|
| 58 |
+// issue #11: gate on the rating aggregate, not the text-review count. |
|
| 59 |
+// With Allow Ratings Only, every review is the 'No Review' sentinel, so |
|
| 60 |
+// $totalcount is 0 and the recomputed rating never landed. AVG returns |
|
| 61 |
+// NULL when nothing was rated, so the update still stays silent then; |
|
| 62 |
+// dropping ?? 0 is safe inside the guard (and PHP 5 friendly, issue #10). |
|
| 63 |
+if($totalreviews !== null) $update = dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET rating = '".round($totalreviews)."', reviews = '$totalcount' WHERE seriesid = '$thisseries'");
|
|
| 59 | 64 |
$parentq = dbquery("SELECT seriesid FROM ".TABLEPREFIX."fanfiction_inseries WHERE subseriesid = '$thisseries' AND seriesid != '$thisseries'");
|
| 60 | 65 |
if(dbnumrows($parentq) > 0) list($parent) = dbrow($parentq); |
| 61 | 66 |
else $parent = false; |
| ... | ... |
@@ -87,7 +92,8 @@ while($parent) {
|
| 87 | 92 |
") AND review != 'No Review'"); |
| 88 | 93 |
list($total) = dbrow($pnewrating); |
| 89 | 94 |
list($totalcount) = dbrow($pnewcount); |
| 90 |
- if($total) $update = dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET rating = '".round($total ?? 0)."', reviews = '$totalcount' WHERE seriesid = '$parent' AND rating != '-1'");
|
|
| 95 |
+ // same issue #11 gate for the parent-series walk |
|
| 96 |
+ if($total !== null) $update = dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET rating = '".round($total)."', reviews = '$totalcount' WHERE seriesid = '$parent' AND rating != '-1'");
|
|
| 91 | 97 |
$parentq = dbquery("SELECT seriesid FROM ".TABLEPREFIX."fanfiction_inseries WHERE subseriesid = '$parent'");
|
| 92 | 98 |
if(dbnumrows($parentq)) list($parent) = dbrow($parentq); |
| 93 | 99 |
else $parent = false; |