0 implode(): Argument #1 ($pieces) must be of type array, string given

This forum is for general questions about extensions for Joomla! 3.x.

Moderators: pe7er, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
Ch3vr0n
Joomla! Explorer
Joomla! Explorer
Posts: 439
Joined: Sat Sep 26, 2009 11:00 pm
Location: Belgium
Contact:

0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by Ch3vr0n » Fri Jan 21, 2022 6:53 pm

When changing hosting config from PHP 7.4.x to 8.0.x the above error appears when trying to REGISTER a new user (from the front-end). The registration itself does go through to the backend as the newly registered account is listed in the backend.
0 implode(): Argument #1 ($pieces) must be of type array, string given.
Trying to modify an existing user on the backend gives the same error, but the change IS saved.

Setting error reporting on the backend to "development" gives the following error.
Warning: Trying to access array offset on value of type null in /var/www/vhosts/<domain.tld>/httpdocs/administrator/templates/isis/html/com_users/users/default.php on line 96
Go back to 7.4 and the backend warning stays but front-end registration behaves just fine and an activation link is e-mailed.
Last edited by toivo on Fri Jan 21, 2022 9:10 pm, edited 1 time in total.
Reason: mod note: moved from 3.x Administration

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 14587
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: 0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by toivo » Fri Jan 21, 2022 9:04 pm

Ch3vr0n wrote:
Fri Jan 21, 2022 6:53 pm
0 implode(): Argument #1 ($pieces) must be of type array, string given.
The only place where Joomla 3.x uses $pieces is the file libraries/vendor/paragonie/sodium_compat/src/Compat.php. It is more likely that this variable or the Libsodium compatibility layer is used by a third party extension, especially because you recently asked about these errors in the HikaShop forum.

Ch3vr0n wrote:
Fri Jan 21, 2022 6:53 pm
Warning: Trying to access array offset on value of type null in /var/www/vhosts/<domain.tld>/httpdocs/administrator/templates/isis/html/com_users/users/default.php on line 96
Joomla 3.x does not come with a com_users sub folder in the html folder of the Isis template. The file default.php was created there as a template override of the users view and modified, in other words, the root cause of this error is in customised code.
Toivo Talikka, Global Moderator

Ch3vr0n
Joomla! Explorer
Joomla! Explorer
Posts: 439
Joined: Sat Sep 26, 2009 11:00 pm
Location: Belgium
Contact:

Re: 0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by Ch3vr0n » Fri Jan 21, 2022 9:11 pm

How'd you know I asked this over there too? My precise reason to ask here was too hopefully gain some info they haven't thought of yet that i could relay back over there.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 14587
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: 0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by toivo » Sat Jan 22, 2022 1:14 am

Ch3vr0n wrote:
Fri Jan 21, 2022 9:11 pm
How'd you know I asked this over there too?
It is common practice to do a search when an unusual looking error is reported.

Ch3vr0n wrote:
Fri Jan 21, 2022 9:11 pm
My precise reason to ask here was too hopefully gain some info they haven't thought of yet that i could relay back over there.
That is perfectly all right, because now you can pass on the following info:

Code: Select all

        $pieces = explode('$', (string) $hash);
        $prefix = implode('$', array_slice($pieces, 0, 4));
Let's look at the only two lines in the whole of Joomla core that could generate the implode() error. The first line produces always an array $pieces, even if it were an empty array. Therefore it is impossible that the error message you reported comes from the implode() function of the second line, in the Libsodium compatibility layer of the Joomla core.

Ref. https://www.php.net/manual/en/function.explode.php
Toivo Talikka, Global Moderator

Ch3vr0n
Joomla! Explorer
Joomla! Explorer
Posts: 439
Joined: Sat Sep 26, 2009 11:00 pm
Location: Belgium
Contact:

Re: 0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by Ch3vr0n » Sat Jan 22, 2022 8:07 pm

info forwarded, any chance this could have a negative impact on upgrading to J4? (or potentially fix it?)

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 14587
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: 0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by toivo » Sat Jan 22, 2022 9:18 pm

You should install the Wampserver bundle in your Windows workstation with PHP 7.4 and PHP 8.0 as extensions, then back up the live website using Akeeba Backup and restore into the localhost by using the Akeeba Kickstart utility. This would be a perfect test environment to debug and find out where the first PHP error comes from and then upgrade from Joomla 3.10 to Joomla 4.0. It would help in testing other third party extensions, too.
Toivo Talikka, Global Moderator

Ch3vr0n
Joomla! Explorer
Joomla! Explorer
Posts: 439
Joined: Sat Sep 26, 2009 11:00 pm
Location: Belgium
Contact:

Re: 0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by Ch3vr0n » Sat Jan 22, 2022 9:35 pm

no windows workstation here lol. Small webhoster here with a couple VPS's managing sites & registration of domains for a couple local businesses. The site this is happening on is one of them. Did some more digging. Out of curiousity i figured lets check out the actual file. The code line is this:

Code: Select all

$allowed_admins_prm_arr[] = $allowed_admins_prm[0];
Doesn't look like hikashop code to me, and had i not initially scrolled down to line 96 i would not even have to look at the code. From the file header:

Code: Select all

/* ======================================================
# Login as User for Joomla! - v3.4.1 (Pro version)
# -------------------------------------------------------
# For Joomla! CMS
# Author: Web357 (Yiannis Christodoulou)
# Copyright (©) 2009-2020 Web357. All rights reserved.
# License: GNU/GPLv3, http://www.gnu.org/licenses/gpl-3.0.html
# Website: https:/www.web357.com/
# Demo: https://demo.web357.com/joomla/loginasuser
# Support: support@web357.com
# Last modified: 04 Sep 2020, 17:09:33
========================================================= */
This isn't a hikashop problem AT ALL, its a "Login As User" component causing the problem. Uninstalled everything related to it (framework AND component) and still getting the error :s

don't know if its related but when now setting the site debugging i get
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/movi.be/httpdocs/plugins/user/improved_profile/improved_profile.php on line 481

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/movi.be/httpdocs/plugins/user/improved_profile/improved_profile.php on line 483

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/movi.be/httpdocs/plugins/user/improved_profile/improved_profile.php on line 485

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/movi.be/httpdocs/plugins/user/improved_profile/improved_profile.php on line 487

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/movi.be/httpdocs/plugins/user/improved_profile/improved_profile.php on line 489
Didn't see that one before

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 14587
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: 0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by toivo » Sat Jan 22, 2022 10:00 pm

Ch3vr0n wrote:
Sat Jan 22, 2022 9:35 pm
Out of curiousity i figured lets check out the actual file. The code line is this:

Code: Select all

$allowed_admins_prm_arr[] = $allowed_admins_prm[0];
That line does not seem to have anything to do with the errors you reported initially.

BTW, the paid third party extension Login As User was updated three weeks ago but your site had v3.4.1, released in September 2020. It cannot have been tested in PHP 8.0 because PHP 8.0 was released two months later.

Search for the variable $pieces in the PHP source code and you will find the culprit for the first error you reported.
Toivo Talikka, Global Moderator

Ch3vr0n
Joomla! Explorer
Joomla! Explorer
Posts: 439
Joined: Sat Sep 26, 2009 11:00 pm
Location: Belgium
Contact:

Re: 0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by Ch3vr0n » Sat Jan 22, 2022 10:10 pm

@Toivo actually it does. The initial error was the one reported in the topic. Enabling debugging allowed allowed you to say that the relevant code was found in the isis template but that the template itself did NOT come with the com_users folder by default.

So i navigated to the specific folder/file within that template and found the file in question, checked out the headers and thats where i was pointed to "Login As User". It's a chain of events. i know it was updated. My subscription to it expired a little while ago, and as i had no need to use it in the past year, i simply uninstalled it (and its framework). My assumption was that with the component/framework uninstalled, the problem would fix itself.

Logic dictates that uninstalling the component responsible for the file in the templates folder would fix things. I guess not not. I verified the file was removed. Cleared browser cache, still happens.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 14587
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: 0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by toivo » Sat Jan 22, 2022 10:21 pm

Ch3vr0n wrote:
Sat Jan 22, 2022 9:35 pm
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/movi.be/httpdocs/plugins/user/improved_profile/improved_profile.php on line 481
The plugin User - Improved Profile is a third party extension, about which searches find only a couple of references from 7 years ago. The installed version is not compatible with PHP 7.3 and above, even if it may still run if you turn off error reporting.

Updating, replacing or removing incompatible third party extensions is an important step in the Joomla 3.x to 4.x Step by Step Migration.
Last edited by toivo on Sun Jan 23, 2022 4:05 am, edited 1 time in total.
Reason: typo
Toivo Talikka, Global Moderator

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 14587
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: 0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by toivo » Sat Jan 22, 2022 10:38 pm

Ch3vr0n wrote:
Sat Jan 22, 2022 10:10 pm
So i navigated to the specific folder/file within that template and found the file in question, checked out the headers and thats where i was pointed to "Login As User".
So the html folder of the Isis template had also and override for 'Login As User', not just an override for for the Users view of com_user? Or is 'Login As User' available from the front end?

Ch3vr0n wrote:
Sat Jan 22, 2022 10:10 pm
Logic dictates that uninstalling the component responsible for the file in the templates folder would fix things. I guess not not. I verified the file was removed. Cleared browser cache, still happens.
Use the debug option and also enable the plugin System - Debug for your user group, Super Users. The stack trace will have full information where those errors occur.

The Forum Post Assistant (FPA) results could also offer some clues to our volunteer experts. Please follow the instructions at https://forumpostassistant.github.io/docs/. The results will give you an inventory of the website and its extensions in a compact format.
Toivo Talikka, Global Moderator

Ch3vr0n
Joomla! Explorer
Joomla! Explorer
Posts: 439
Joined: Sat Sep 26, 2009 11:00 pm
Location: Belgium
Contact:

Re: 0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by Ch3vr0n » Sat Jan 22, 2022 11:25 pm

toivo wrote:
Sat Jan 22, 2022 10:38 pm
So the html folder of the Isis template had also and override for 'Login As User', not just an override for for the Users view of com_user? Or is 'Login As User' available from the front end?
Just login as user, as specified. It's behavior allows to login on the front-end (hadn't need to try it on the backend), to login as a specific user without having to know its password (eg when a shop user says they can't find something in their shop account that's supposed to be visible) and thus keeping the user password integrety intact and without having to ask the user for their password. It is and was the single override in question. The fact that it had an override in the isis template seems to indicate it had that functionality for the backend too.
toivo wrote:The plugin User - Improved Profile is a third party extension,


Found that culprit, removed it and registration now completes normally and activation link gets sent.
toivo wrote:
Sat Jan 22, 2022 10:38 pm
Use the debug option and also enable the plugin System - Debug for your user group, Super Users. The stack trace will have full information where those errors occur.
Found the plugin (had too look around as i'm using nl-BE locale and its called differently). Changed "allowed groups" to superuser. Anything i should change on the "Logging" tab or change on the "language" tab? Thanks to that tip i found some plugins that "improved ajax login & register" didn't uninstall when it got uninstalled. Tsss, messy coding.

I'll try to remember the FPA for next time. I know it exists and have a permanent copy on one of my system drives.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 14587
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: 0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by toivo » Sun Jan 23, 2022 4:25 am

Ch3vr0n wrote:
Sat Jan 22, 2022 11:25 pm
Anything i should change on the "Logging" tab or change on the "language" tab?
The most useful option is 'Log Almost Everything', which sets up the log file to be written into the file administrator/logs/everything.php. Usually I do not make changes in the Language tab, or just turn off the options, to minimise the length of the log.

Joomla 4.0 has a new tab in Global Configuration called 'Logging' with a few options, but the rest of the selections are still found in the plugin System - Debug.

BTW, are all the errors, warnings etc now sorted out?
Toivo Talikka, Global Moderator

Ch3vr0n
Joomla! Explorer
Joomla! Explorer
Posts: 439
Joined: Sat Sep 26, 2009 11:00 pm
Location: Belgium
Contact:

Re: 0 implode(): Argument #1 ($pieces) must be of type array, string given

Post by Ch3vr0n » Sun Jan 23, 2022 1:07 pm

Good to know. I'll change that setting. And i think they are. There was one about a hikashop file reporting a zen compile error in php itself to report but i can't get it to reproduce. Can't do anymore testing this weekend but i believe getting rid of those 2 outdated (and unused) extensions fixed the registration problem and warnings on both frontend and backend. I'll report bask asap.


Post Reply

Return to “Extensions for Joomla! 3.x”