functions_content.php error : Trying to access array offset on value of type bool

Get help with installation and running phpBB 3.3.x here. Please do not post bug reports, feature requests, or extension related questions here.
exemplary1
Registered User
Posts: 216
Joined: Mon Feb 05, 2024 11:41 am

functions_content.php error : Trying to access array offset on value of type bool

Post by exemplary1 »

Clicking on Posts number in post profile, this error appears.
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 413: Trying to access array offset on value of type bool
There is atleast one local language character which is causing this error.

lines 412 and 413 of /includes/functions_content.php

Code: Select all

	
{
	preg_match_all('/[a-zA-Z0-9][^a-zA-Z0-9]/u', $fragment, $matches, PREG_OFFSET_CAPTURE);
	$fragment_end = end($matches[0])[1]; // last valid alphanumeric character
}
Edit : I am using latest Phpbb 3.3.13
It shows all the posts of a user but with above error. If I remove that particular character, error disappears.
Last edited by Mick on Sat Sep 28, 2024 8:08 am, edited 1 time in total.
Reason: Solved.
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3999
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by Kailey »

What PHP version? Also, have you tried deleting everything in the /cache/ directory except for .htaccess and index.htm?

See below post
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules
If you have any questions about the rules/customs of this website, feel free to send me a PM.

My little corner of the world | Administrator @ phpBB Modders
rxu
Extensions Development Team
Posts: 3982
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by rxu »

I think this is the same bug as here https://tracker.phpbb.com/browse/PHPBB-17387.
exemplary1
Registered User
Posts: 216
Joined: Mon Feb 05, 2024 11:41 am

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by exemplary1 »

I did a little google search and most people having such issues in phpbb or other web software, is mostly due to upgrading PHP to version 8 from 7.x.

In my localhost I have PHP 7.2, and it works, while on my Webhost I have 8.x version.
rxu
Extensions Development Team
Posts: 3982
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by rxu »

exemplary1 wrote: Fri Sep 27, 2024 6:27 am PHP 7.2, and it works
This is due PHP 8 has changed the way errors are handled. In other words, the bug is still there but error is not displayed on PHP 7 and is displayed on PHP 8.
exemplary1
Registered User
Posts: 216
Joined: Mon Feb 05, 2024 11:41 am

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by exemplary1 »

rxu wrote: Fri Sep 27, 2024 7:31 am
exemplary1 wrote: Fri Sep 27, 2024 6:27 am PHP 7.2, and it works
This is due PHP 8 has changed the way errors are handled. In other words, the bug is still there but error is not displayed on PHP 7 and is displayed on PHP 8.
I see.
I would like to add that on both PHP 7 and PHP 8, the searched post(s) shows 1st character only out of post.
I dont understand how a character can cause the problem. Because as I said earlier, if I remove that character, there is no error and search post is shown (not just 1st character).
rxu
Extensions Development Team
Posts: 3982
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by rxu »

exemplary1 wrote: Fri Sep 27, 2024 7:43 am I dont understand how a character can cause the problem.
That's because of the regular expression used which spans only alphanuneric characters. It's a bug, the ticket is linked above.
exemplary1
Registered User
Posts: 216
Joined: Mon Feb 05, 2024 11:41 am

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by exemplary1 »

Thank you !
It shows Resolution : Fixed. So, is solution available ? Am I missing something ?
rxu
Extensions Development Team
Posts: 3982
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by rxu »

The PR https://github.com/phpbb/phpbb/pull/6712 has been merged into the core.
exemplary1
Registered User
Posts: 216
Joined: Mon Feb 05, 2024 11:41 am

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by exemplary1 »

rxu wrote: Fri Sep 27, 2024 8:09 am The PR https://github.com/phpbb/phpbb/pull/6712 has been merged into the core.
Sorry, I dont understand.
Do I have to wait for next update ? Or I need to change manually,
https://github.com/phpbb/phpbb/pull/671 ... af589bdcf8
rxu
Extensions Development Team
Posts: 3982
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by rxu »

I've just linked the fix requested :) Next is up to you, if you're experienced and confident enough when it comes to manual code manupulation, you can try applying the fix. Otherwise it'd be better to wait until v.3.3.14 got released.
exemplary1
Registered User
Posts: 216
Joined: Mon Feb 05, 2024 11:41 am

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by exemplary1 »

I think I will wait for the update, but might try on localhost. Thank you so much for the help !
rxu
Extensions Development Team
Posts: 3982
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by rxu »

To simplify, the whole function get_context can be just replaced.
exemplary1
Registered User
Posts: 216
Joined: Mon Feb 05, 2024 11:41 am

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by exemplary1 »

rxu wrote: Fri Sep 27, 2024 11:33 am To simplify, the whole function get_context can be just replaced.
Voila, just replaced the function on localhost and its showing the contents in posts search. Will update here after making changes on website.
Thank you once again !
exemplary1
Registered User
Posts: 216
Joined: Mon Feb 05, 2024 11:41 am

Re: functions_content.php error : Trying to access array offset on value of type bool

Post by exemplary1 »

Made changes and working on website.

Return to “[3.3.x] Support Forum”