[SOLVED] PHP 7.2 Count() Warning In /includes/functions_messenger.php

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
User avatar
linux4me
Registered User
Posts: 59
Joined: Fri Oct 03, 2008 6:39 pm

[SOLVED] PHP 7.2 Count() Warning In /includes/functions_messenger.php

Post by linux4me »

I'm running phpBB 3.2.2 on a server that is running PHP 7.2. I see in other posts that prior to release of 3.2.2, there were some issues with PHP 7.2's handling of the count() function that were due to twig. This morning, a user contacted me about a PHP warning message he got that he says occurred when he submitted a new post. The PHP warning he got was:

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_messenger.php on line 506: count(): Parameter must be an array or an object that implements Countable
The code on line 506 of /includes/functions.php is:

Code: Select all

if (count($this->extra_headers))
{
	$headers = array_merge($headers, $this->extra_headers);
}
There is nothing in ACP -> Maintenance -> Error Log (maybe because this is a warning and not an error?) and nothing in my error logs except "headers already sent" messages from the users getting the warning output above.

I downloaded a fresh copy of phpBB 3.2.2 and compared the /includes/functions_messenger.php I'm using on the site with a clean copy, and they're identical.

I know PHP 7.2 throws such warnings if the parameter passed to count() is not an array, which is what appears to be happening here. Is this particular code something that sneaked through in version 3.2.2 without being modified for PHP 7.2, or is there something else I should be looking at?
Last edited by linux4me on Wed Feb 14, 2018 4:46 pm, edited 1 time in total.

User avatar
AbaddonOrmuz
Recognised Extension Developer
Posts: 823
Joined: Wed Dec 25, 2013 9:06 pm
Location: /dev/null
Name: Alfredo Ramos
Contact:

Re: PHP 7.2 Count() Warning In /includes/functions_messenger.php

Post by AbaddonOrmuz »

I think it can be fixed declaring that variable as array in includes/function_messenger.php

Code: Select all

class messenger
{
	var $msg, $replyto, $from, $subject;
	var $$extra_headers = array();
	var $addresses = array();
Some of my phpBB extensions:
Image Imgur | :chart_with_upwards_trend: SEO Metadata | Image Markdown | :lock: Auto-lock Topics
:trophy: Check out all my validated extensions :trophy:

:penguin: Arch Linux user :penguin:

hubaishan
Translator
Posts: 141
Joined: Sun Apr 10, 2011 2:47 pm
Name: Saeed Hubaishan
Contact:

Re: PHP 7.2 Count() Warning In /includes/functions_messenger.php

Post by hubaishan »


User avatar
linux4me
Registered User
Posts: 59
Joined: Fri Oct 03, 2008 6:39 pm

Re: PHP 7.2 Count() Warning In /includes/functions_messenger.php

Post by linux4me »

Thank you both. That's what I was looking for. I didn't want to make a change that was inconsistent with what the developers were planning.

Post Reply

Return to “[3.2.x] Support Forum”