Support

Admin Tools

#35921 An error has occurred. 0 in_array(): Argument #2 ($haystack) must be of type array, string given

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by on Friday, 05 November 2021 20:17 CDT

vanboke

I am seeing an error if I happen to access the Joomla administrator without the correct Administrator secret URL parameter in the URL.  The error is:

An error has occurred. 0 in_array(): Argument #2 ($haystack) must be of type array, string given

As long as I have the correct Administrator secret URL parameter in the URL I don't see the error.  Pre-Joomla 4 as you know it would redirect to the home page of the website.  Now it just shows that error in the place where the Joomla 4 administrator login should be.

Any thoughts on a fix?  Do you need any more information from me on this?

nicholas
Akeeba Staff
Manager

I cannot reproduce this using your issue description. On a new Joomla 4.0.3 site with Admin Tools 7.0.5 installed I set up a secret word (foobar). When I try to access the backend as /administrator/index.php?invalid, just  /administrator/index.php or /administrator I get redirected to the front-page and I get a blocked request logged as expected. When I access the backend as /administrator/index.php?foobar I see the login page, again as expected.

Please go to Global Configuration on your site and set Error Reporting to Maximum and Debug Site to Yes. Save & Close. Then open a new Private Mode instance of your browser (this ensures a clean session in Joomla) and try to access your backend with the wrong or none at all secret URL parameter. It will give you much more detailed information. Please copy it here. It tells me the chain of events that led to the error and exactly where it comes from. Afterwards remember to set Error Reporting back to None and Debug Site to No.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

vanboke

Here is the debug information you requested.  Let me know what you think.

An error has occurred.  
0 in_array(): Argument #2 ($haystack) must be of type array, string given
Call stack # Function Location 1 () JROOT/plugins/system/admintools/src/Utility/BlockedRequestHandler.php:1009 2 in_array() JROOT/plugins/system/admintools/src/Utility/BlockedRequestHandler.php:1009 3 Joomla\Plugin\System\AdminTools\Utility\BlockedRequestHandler->emailSecurityException() JROOT/plugins/system/admintools/src/Utility/BlockedRequestHandler.php:428 4 Joomla\Plugin\System\AdminTools\Utility\BlockedRequestHandler->logBlockedRequest() JROOT/plugins/system/admintools/src/Utility/BlockedRequestHandler.php:103 5 Joomla\Plugin\System\AdminTools\Utility\BlockedRequestHandler->logWithoutBlocking() JROOT/plugins/system/admintools/src/Feature/AdminSecretWord.php:103 6 Joomla\Plugin\System\AdminTools\Feature\AdminSecretWord->checkSecretWord() JROOT/plugins/system/admintools/src/Feature/AdminSecretWord.php:46 7 Joomla\Plugin\System\AdminTools\Feature\AdminSecretWord->onAfterInitialise() JROOT/plugins/system/admintools/src/Extension/AdminTools.php:859 8 Joomla\Plugin\System\AdminTools\Extension\AdminTools->runFeature() JROOT/plugins/system/admintools/src/Extension/AdminTools.php:252 9 Joomla\Plugin\System\AdminTools\Extension\AdminTools->onAfterInitialise() JROOT/libraries/vendor/joomla/event/src/Dispatcher.php:486 10 Joomla\Event\Dispatcher->dispatch() JROOT/libraries/src/Application/EventAware.php:111 11 Joomla\CMS\Application\WebApplication->triggerEvent() JROOT/libraries/src/Application/CMSApplication.php:740 12 Joomla\CMS\Application\CMSApplication->initialiseApp() JROOT/libraries/src/Application/AdministratorApplication.php:354 13 Joomla\CMS\Application\AdministratorApplication->initialiseApp() JROOT/libraries/src/Application/AdministratorApplication.php:165 14 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:278 15 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/includes/app.php:63 16 require_once() JROOT/administrator/index.php:32

vanboke

One more thing I found.  I created a temporary super admin account with AdminTools and when I saved it I got this error:

Save failed with the following error: Field 'automation' doesn't have a default value

The user account was created and does work, but the entry was never entered in AdminTools so I assume it will not auto expire.

Thanks for looking into these issues for me.

nicholas
Akeeba Staff
Manager

PHP Error: I believe you have left “Do not send email notifications for these reasons” completely empty. This will indeed trigger this error. It will be addressed in the next version of Admin Tools.

Temporary Super User: I cannot reproduce this issue on the same Joomla and PHP version. There is no field called automation on that form or the database table; there never was, in fact. My only guess is that there must be a third party extension doing pre-processing of forms without checking the form context correctly. Since we are using Joomla core MVC all our forms go through the standard Joomla pre–processing events which means that third party plugins can modify them.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

vanboke

PHP Error: It wasn't empty.  It had "Site IP Disallow List" in it.  I added "Admin Query String" though and it solved the problem.  I assume that there is an issue with the sending of notifications that caused the PHP error.  At least the PHP error isn't showing any longer.  If you need any assistance in recreating this issue for resolving it in an upcoming version, let me know.

Temporary Super User: I found the issue.  It was a DB default value issue in AcyMailing that was causing the issue.  I got that issue resolved and the creation of temporary super users now works fine.

nicholas
Akeeba Staff
Manager

The email notification code is common, it does not make sense to have different email code for each type of blocked request. The list was empty. Because of the quirky way Joomla works, an empty list causes Joomla to populate it with the default value. The default value is indeed just the “Site IP Disallow List”. If you had just saved that page the problem would have gone away.

The problem is now moot as I added some code to expect an empty list in a way that does not throw an error in PHP 8. For what it's worth, the code was written in a way that PHP 5 and PHP 7 only threw a Notice (which was absorbed) without causing a problem. With PHP 8 the PHP internal functions are now type–safe meaning that we can no longer use that shortcut. We did try to catch as much as we could but the reality is that this kind of fundamental changes are nearly impossible to be addressed in automated tests and code review; they are something the developer needs to have in mind when writing the code in the first place. We expect a couple of these edge cases we didn't think about to crop up.

Yes, I understand that the way the Configure WAF, .htaccess Maker etc forms behave now is frustrating by not letting you have an empty list without falling back to the default value. That's how Joomla decided to implement forms back in Joomla 1.5. Not much we can do about it. I am currently experimenting with adding “fake” items, i.e. items which don't actually do anything except satisfy the non–empty list requirement to prevent the default value kicking in. While that works, it's confusing to the end user. If, for example, I name it “None” what does including “None” and ”Admin Query String” in the same list is supposed to do? Trying to understand what is less confusing for the user is a complicated matter...

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

System Task
system
This ticket has been automatically closed. All tickets which have been inactive for a long time are automatically closed. If you believe that this ticket was closed in error, please contact us.

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!