reviews.php: Trying to access array offset on null PHP warning when accessing a nonexistent story's review page dirty fix
--- a/reviews.php
+++ b/reviews.php
@@ -264,7 +264,7 @@
$storyquery = dbquery("SELECT s.title, s.uid, s.rid, s.sid, s.coauthors FROM ".TABLEPREFIX."fanfiction_stories as s WHERE s.sid = '$item' LIMIT 1");
$story = dbassoc($storyquery);
$title = title_link($story);
- $authoruid = $story['uid'];
+ $authoruid = ($story['uid']) ?? null;
$array_coauthors = array();
if(!empty($story['coauthors'])) {
$colist = dbquery("SELECT uid FROM ".TABLEPREFIX."fanfiction_coauthors WHERE sid = '$item'");
@@ -346,11 +346,11 @@
}
$jumpmenu = "<form name=\"jump\" action=\"\">";
$jumpmenu .= "<select name=\"sid\" onChange=\"window.location=this.options[this.selectedIndex].value\">";
- $jumpmenu .= "<option value=\"reviews.php?type=ST&item=".$story['sid'].(isset($_GET['unresponded']) ? "&unresponded=1" : "")."\"";
+ $jumpmenu .= "<option value=\"reviews.php?type=ST&item=".(($story['sid']) ?? null).(isset($_GET['unresponded']) ? "&unresponded=1" : "")."\"";
if(!isset($chapid))
$jumpmenu .= " selected";
$jumpmenu .= ">"._VIEWALLREVIEWS."</option>";
- $chapquery = dbquery("SELECT inorder, title, chapid, sid FROM ".TABLEPREFIX."fanfiction_chapters WHERE sid = '".$story['sid']."' ORDER BY inorder ASC");
+ $chapquery = dbquery("SELECT inorder, title, chapid, sid FROM ".TABLEPREFIX."fanfiction_chapters WHERE sid = '".(($story['sid']) ?? null)."' ORDER BY inorder ASC");
while($chapters = dbassoc($chapquery)) {
$jumpmenu .= "<option value=\"reviews.php?chapid=".$chapters['chapid'].(isset($_GET['unresponded']) ? "&unresponded=1" : "")."&type=ST&item=$item\"";