Browse code

reviews.php: Trying to access array offset on null PHP warning when accessing a nonexistent story's review page dirty fix

Clarissa Walker authored on 2026/09/19 19:16:04
Showing 1 changed files
... ...
@@ -264,7 +264,7 @@ else {
264 264
 		$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");
265 265
 		$story = dbassoc($storyquery);
266 266
 		$title = title_link($story);
267
-		$authoruid = $story['uid'];
267
+		$authoruid = ($story['uid']) ?? null;
268 268
 		$array_coauthors = array();
269 269
 		if(!empty($story['coauthors'])) {
270 270
 			$colist = dbquery("SELECT uid FROM ".TABLEPREFIX."fanfiction_coauthors WHERE sid = '$item'");
... ...
@@ -346,11 +346,11 @@ else {
346 346
 		}
347 347
 		$jumpmenu = "<form name=\"jump\" action=\"\">";
348 348
 		$jumpmenu .= "<select name=\"sid\" onChange=\"window.location=this.options[this.selectedIndex].value\">";
349
-		$jumpmenu .= "<option value=\"reviews.php?type=ST&amp;item=".$story['sid'].(isset($_GET['unresponded']) ? "&amp;unresponded=1" : "")."\"";
349
+		$jumpmenu .= "<option value=\"reviews.php?type=ST&amp;item=".(($story['sid']) ?? null).(isset($_GET['unresponded']) ? "&amp;unresponded=1" : "")."\"";
350 350
 		if(!isset($chapid))
351 351
 			$jumpmenu .= " selected";
352 352
 		$jumpmenu .= ">"._VIEWALLREVIEWS."</option>";
353
-		$chapquery = dbquery("SELECT inorder, title, chapid, sid FROM ".TABLEPREFIX."fanfiction_chapters WHERE sid = '".$story['sid']."' ORDER BY inorder ASC");
353
+		$chapquery = dbquery("SELECT inorder, title, chapid, sid FROM ".TABLEPREFIX."fanfiction_chapters WHERE sid = '".(($story['sid']) ?? null)."' ORDER BY inorder ASC");
354 354
 		while($chapters = dbassoc($chapquery)) {
355 355
 			$jumpmenu .= "<option value=\"reviews.php?chapid=".$chapters['chapid'].(isset($_GET['unresponded']) ? "&amp;unresponded=1" : "")."&amp;type=ST&amp;item=$item\"";
356 356