Browse code

news.php: Trying to access array offset on null warning for PHP 8 users dirty fix

Clarissa Walker authored on 2026/10/29 00:30:42
Showing 1 changed files
... ...
@@ -63,17 +63,17 @@ if($nid) {
63 63
 	$news->newBlock("newsbox");
64 64
 
65 65
 	//assign values
66
-	$news->assign("newstitle"   , stripslashes($stories['title']) );
67
-	$news->assign("newsstory"   , format_story($stories['story']) );
68
-	$news->assign("newsauthor", stripslashes($stories['author']) );
69
-	$news->assign("newsid", $stories['nid']);
66
+	$news->assign("newstitle"   , stripslashes(isset($stories['title']) ? $stories['title'] : null) );
67
+	$news->assign("newsstory"   , format_story(isset($stories['story']) ? $stories['story'] : null) );
68
+	$news->assign("newsauthor", stripslashes(isset($stories['author']) ? $stories['author'] : null) );
69
+	$news->assign("newsid", (isset($stories['nid']) ? $stories['nid'] : null) );
70 70
 	$news->assign("oddeven", "odd");
71 71
 	$news->assign("skindir", $skindir);
72
-	$news->assign("newsdate", date("$dateformat $timeformat", $stories['date']) );
72
+	$news->assign("newsdate", date("$dateformat $timeformat", (isset($stories['date']) ? $stories['date'] : null) ) );
73 73
 	if($newscomments)
74
-		$news->assign("newscomments", "<a href=\"news.php?action=newsstory&amp;nid=".$stories['nid']."\">".$stories['comments']." "._COMMENTS."</a>");
74
+		$news->assign("newscomments", "<a href=\"news.php?action=newsstory&amp;nid=".(isset($stories['nid']) ? $stories['nid'] : null)."\">".(isset($stories['comments']) ? $stories['comments'] : null)." "._COMMENTS."</a>");
75 75
 	if(isADMIN && uLEVEL < 4) 
76
-		$news->assign("adminoptions", "<a href=\"admin.php?action=news&amp;form=".$stories['nid']."\">"._EDIT."</a> | <a href=\"admin.php?action=news&amp;delete=".$stories['nid']."\">"._DELETE."</a>");
76
+		$news->assign("adminoptions", "<a href=\"admin.php?action=news&amp;form=".(isset($stories['nid']) ? $stories['nid'] : null)."\">"._EDIT."</a> | <a href=\"admin.php?action=news&amp;delete=".(isset($stories['nid']) ? $stories['nid'] : null)."\">"._DELETE."</a>");
77 77
 	$output .= $news->getOutputContent( );
78 78
 
79 79
 	$cquery = dbquery("SELECT COUNT(cid) FROM ".TABLEPREFIX."fanfiction_comments WHERE nid = '$nid'");