MyBB Community Forums

Full Version: search.php warnings 1.8.36
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In search.php generates a warning.


<error>
	<dateline>1693933805</dateline>
	<datetime>2023-09-05 17:10:05 UTC -0500</datetime>
	<script>search.php(983) : eval()'d code</script>
	<line>2</line>
	<type>2</type>
	<friendly_type>Warning</friendly_type>
	<message>Trying to access array offset on value of type null</message>
	<back_trace>#0  errorHandler->error() called at [/inc/class_error.php:153]
#1  errorHandler->error_callback() called at [/search.php(983) : eval()'d code:2]
#2  eval() called at [/search.php:983]
</back_trace>
</error>

line 983 calls the forumdisplay_thread_gotounread template which contains
<a href="{$thread['newpostlink']}"><img src="{$theme['imgdir']}/jump.png" alt="{$lang->goto_first_unread}" title="{$lang->goto_first_unread}" /></a> 
in which there is an undefined array element 'newpostlink'.

Strictly speaking, it could be called 'unreadpostlink', but that would require defining it in code and changing the template content.

This fix clears the error.

find near line 979
			if($post['thread_lastpost'] > $last_read && $last_read)
			{
				$folder .= "new";
				$folder_label .= $lang->icon_new;
				eval("\$gotounread = \"".$templates->get("forumdisplay_thread_gotounread")."\";");
				$unreadpost = 1;
			}
and replace with
			if($post['thread_lastpost'] > $last_read && $last_read)
			{
				$folder .= "new";
				$folder_label .= $lang->icon_new;
				$thread['newpostlink'] = get_thread_link($post['thread_lastpost']); // added line, core edit
				eval("\$gotounread = \"".$templates->get("forumdisplay_thread_gotounread")."\";");
				$unreadpost = 1;
			}