Need help with the old "Countable" error, please

Get help with installation and running phpBB 3.3.x here. Please do not post bug reports, feature requests, or extension related questions here.
Holger Laux
Registered User
Posts: 20
Joined: Fri May 19, 2017 8:05 pm

Need help with the old "Countable" error, please

Post by Holger Laux »

Hi,

I know this has been discussed before in relation to a different file (back in 2018), but I seem to run into the old error
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/language/language.php on line 307: count(): Parameter must be an array or an object that implements Countable
My observations are as follows:

- In March this year, I updated phpBB from 3.2.2 to 3.3.0.
- Last week, my board suddenly stopped working, giving me just a white screen with the above message.
- I went to my provider's cPanel and found it was running PHP 7.2 with the option to switch it to 7.3.

This I did and at least I can access my board again, but at the top of the screen I still get this error message.

Line 307 of the file says

Code: Select all

if (count($args) === 0)
but in line 295 I find

Code: Select all

public function lang_array($key, $args = array())
It seems $args is already defined as an array? What else can I do to get rid of the error?

Many thanks for your help.
rxu
Extensions Development Team
Posts: 3537
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Need help with the old "Countable" error, please

Post by rxu »

Good catch. On line 307 the count() is applied to the string type variable which is a bug.
It should be rather if (empty($args)) or $args() should be cast to array only.

EDIT: filed a ticket for you https://tracker.phpbb.com/browse/PHPBB3-16505
Last edited by rxu on Mon Jun 01, 2020 10:09 am, edited 2 times in total.
User avatar
3Di
Former Team Member
Posts: 16696
Joined: Mon Apr 04, 2005 11:09 pm
Location: Have a guess... 🇮🇹
Name: Marco
Contact:

Re: Need help with the old "Countable" error, please

Post by 3Di »

Okay. But how to replicate the issue?

if (empty($args)) in such case I think should be the way to go.
๐Ÿ†“ Free support for our extensions also provided here: phpBB Studio
๐Ÿš€ Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity ยบ PhpStorm's proud user ยบ Extensions, Scripts, MOD porting, Update/Upgrades
rxu
Extensions Development Team
Posts: 3537
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Need help with the old "Countable" error, please

Post by rxu »

Technically - if you call lang_array() function directly (which is possible as it's public). F.e.
$language->lang_array('BROWSING_FORUM', 'Some users');
User avatar
3Di
Former Team Member
Posts: 16696
Joined: Mon Apr 04, 2005 11:09 pm
Location: Have a guess... 🇮🇹
Name: Marco
Contact:

Re: Need help with the old "Countable" error, please

Post by 3Di »

Okay indeed.
I see that the logic has to be amended in any case - ofcourse - it should be BTW.

But if only for the sake of future readers I would like to know some more details about the OP's board.
Therefore, if it is even possible, the Support Request template filled out and posted here will be much appreciated.
I am not used to ask for that but in this case I feel I have to... :)
๐Ÿ†“ Free support for our extensions also provided here: phpBB Studio
๐Ÿš€ Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity ยบ PhpStorm's proud user ยบ Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
3Di
Former Team Member
Posts: 16696
Joined: Mon Apr 04, 2005 11:09 pm
Location: Have a guess... 🇮🇹
Name: Marco
Contact:

Re: Need help with the old "Countable" error, please

Post by 3Di »

๐Ÿ†“ Free support for our extensions also provided here: phpBB Studio
๐Ÿš€ Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity ยบ PhpStorm's proud user ยบ Extensions, Scripts, MOD porting, Update/Upgrades
Holger Laux
Registered User
Posts: 20
Joined: Fri May 19, 2017 8:05 pm

Re: Need help with the old "Countable" error, please

Post by Holger Laux »

Thank you for your quick and many replies.

Code: Select all

if (empty($args))
cleared the error for me (although I do not exactly know what it does, just copied your suggestion).

Obviously, I cannot give you admin access to my board, but it can be seen and read by the public here:

http://www.dundry.org.uk/forum/

If it's any help in tracing the issue, I can re-instate the previous line for you to see the error.
rxu
Extensions Development Team
Posts: 3537
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Need help with the old "Countable" error, please

Post by rxu »

it seems to be coming from some extension which improperly uses the lang_array() function.
If you feel confident you can temporarily apply this fix https://github.com/phpbb/phpbb/pull/5995/files to break your board and get fatal error tracing to its origin :)
User avatar
david63
Registered User
Posts: 19701
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: Need help with the old "Countable" error, please

Post by david63 »

Holger Laux wrote: โ†‘
Mon Jun 01, 2020 7:58 am
In March this year, I updated phpBB from 3.2.2 to 3.3.0.
Are you sure about that as your board still appears to be running phpBB 3.2.2
Holger Laux wrote: โ†‘
Mon Jun 01, 2020 7:58 am
I went to my provider's cPanel and found it was running PHP 7.2 with the option to switch it to 7.3.
If the above is true then running phpBB 3.2.2 with PHP 7.3 will create problems
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
User avatar
3Di
Former Team Member
Posts: 16696
Joined: Mon Apr 04, 2005 11:09 pm
Location: Have a guess... 🇮🇹
Name: Marco
Contact:

Re: Need help with the old "Countable" error, please

Post by 3Di »

Yup, i am convinced that's not really a phpBB3.3.x's issue, this is me though.
๐Ÿ†“ Free support for our extensions also provided here: phpBB Studio
๐Ÿš€ Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity ยบ PhpStorm's proud user ยบ Extensions, Scripts, MOD porting, Update/Upgrades
Holger Laux
Registered User
Posts: 20
Joined: Fri May 19, 2017 8:05 pm

Re: Need help with the old "Countable" error, please

Post by Holger Laux »

david63 wrote: โ†‘
Mon Jun 01, 2020 12:59 pm
Holger Laux wrote: โ†‘
Mon Jun 01, 2020 7:58 am
In March this year, I updated phpBB from 3.2.2 to 3.3.0.
Are you sure about that as your board still appears to be running phpBB 3.2.2

This is what it says in my System tab:
Screenshot from 2020-06-01 16-22-13.png

But come to think of it, I have a few extensions that I was playing around with but do not really use.
Screenshot from 2020-06-01 16-27-26.png
The problem could be something like Sitemaker. I will have to investigate this more closely.
Holger Laux wrote: โ†‘
Mon Jun 01, 2020 8:58 am
I went to my provider's cPanel and found it was running PHP 7.2 with the option to switch it to 7.3.


If the above is true then running phpBB 3.2.2 with PHP 7.3 will create problems
I only switched to 7.3 because I could not access my board at all.
User avatar
3Di
Former Team Member
Posts: 16696
Joined: Mon Apr 04, 2005 11:09 pm
Location: Have a guess... 🇮🇹
Name: Marco
Contact:

Re: Need help with the old "Countable" error, please

Post by 3Di »

Disable all of your extensions then please tell us if the issue it is still present, thanks.
๐Ÿ†“ Free support for our extensions also provided here: phpBB Studio
๐Ÿš€ Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity ยบ PhpStorm's proud user ยบ Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
warmweer
Jr. Extension Validator
Posts: 7271
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Bel ... gium
Contact:

Re: Need help with the old "Countable" error, please

Post by warmweer »

Holger Laux wrote: โ†‘
Mon Jun 01, 2020 3:30 pm
This is what it says in my System tab:

Screenshot from 2020-06-01 16-22-13.png
Your database has been upgraded to 3.3.0 but your prosilver and prosilver_se are version 3.2.2.
I wonder how you managed that?
Anyway: the "countable" error occured in 1 or 2 3.2.x versions, so I'm also not convinced this is a 3.3.0 error.

If I were you, I would do a files compare between your fileset and a clean 3.3.0 fileset.
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.
Holger Laux
Registered User
Posts: 20
Joined: Fri May 19, 2017 8:05 pm

Re: Need help with the old "Countable" error, please

Post by Holger Laux »

3Di wrote: โ†‘
Mon Jun 01, 2020 4:17 pm
Disable all of your extensions then please tell us if the issue it is still present, thanks.
OK, it looks like Sitemaker was the culprit. It is not (yet) available for 3.3.X, it seems:
Screenshot from 2020-06-01 19-00-47.png
Disabling it makes the message disappear.

Quick question: Shall I keep the suggested edit of language.php or go back to the original version?

I will also go through all the other extensions and see what can be updated and what should be disabled and/or deleted.

Many thanks for your help.
User avatar
3Di
Former Team Member
Posts: 16696
Joined: Mon Apr 04, 2005 11:09 pm
Location: Have a guess... 🇮🇹
Name: Marco
Contact:

Re: Need help with the old "Countable" error, please

Post by 3Di »

Holger Laux wrote: โ†‘
Mon Jun 01, 2020 6:05 pm
Quick question: Shall I keep the suggested edit of language.php or go back to the original version?
Roll it back to the original if you still are using phpBB 3.2.x and ofcourse PHP max. 7.2.x.

The discussion is going on the tracker/github as per the develoment's side of things, still.

Beware there is not support for phpBB 3.2 if you are running on PHP 7.3.x or higher. ;)
๐Ÿ†“ Free support for our extensions also provided here: phpBB Studio
๐Ÿš€ Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity ยบ PhpStorm's proud user ยบ Extensions, Scripts, MOD porting, Update/Upgrades
Post Reply

Return to โ€œ[3.3.x] Support Forumโ€