Error edit category backend

39 views
Skip to first unread message

Yann

unread,
Apr 1, 2024, 1:43:57 AMApr 1
to Joomla! General Development
I get the following error when I want to edit a category in the backend :

An error has occurred.
0 array_key_exists(): Argument #2 ($array) must be of type array, null given
Call stack
# Function Location
1 () JROOT/libraries/src/Association/AssociationExtensionHelper.php:194
2 Joomla\CMS\Association\AssociationExtensionHelper->getTypeTitle() JROOT/administrator/components/com_associations/src/Helper/AssociationsHelper.php:409
3 Joomla\Component\Associations\Administrator\Helper\AssociationsHelper::getSupportedExtension() JROOT/administrator/components/com_associations/src/Helper/AssociationsHelper.php:348
4 Joomla\Component\Associations\Administrator\Helper\AssociationsHelper::getSupportedExtensions() JROOT/administrator/components/com_associations/src/Helper/AssociationsHelper.php:129
5 Joomla\Component\Associations\Administrator\Helper\AssociationsHelper::hasSupport() JROOT/administrator/components/com_categories/src/View/Category/HtmlView.php:244
6 Joomla\Component\Categories\Administrator\View\Category\HtmlView->addToolbar() JROOT/administrator/components/com_categories/src/View/Category/HtmlView.php:121
7 Joomla\Component\Categories\Administrator\View\Category\HtmlView->display() JROOT/administrator/components/com_categories/src/Controller/DisplayController.php:111
8 Joomla\Component\Categories\Administrator\Controller\DisplayController->display() JROOT/libraries/src/MVC/Controller/BaseController.php:693
9 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143
10 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
11 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/AdministratorApplication.php:143
12 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT/libraries/src/Application/AdministratorApplication.php:186
13 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:293
14 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/includes/app.php:61
15 require_once() JROOT/administrator/index.php:32


Here is what is between line 190 and 199 of the "AssociationExtensionHelper" file:

public function getTypeTitle($typeName)
{
    $type = $this->getType($typeName);
   
    if (!\array_key_exists('title', $type)) {  
        return '';
    }

    return $type['title'];
}


If I comment on the "if" for the test, this solves the problem.
My problem is that it's the Joomla framework and I can't go hardcoding a solution. So how can I fix this officially ? Or do you have another explanation/solution ?

Thanks in advance for your help

seraphim

unread,
Apr 2, 2024, 8:06:10 AMApr 2
to joomla-de...@googlegroups.com
If you change:

if (!\array_key_exists('title', $type)) { 

in

if (!\array_key_exists('title', $type ?? '')) { 

the error will be gone.


Op 01-04-2024 om 07:43 schreef Yann:
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/joomla-dev-general/7879e2e2-381d-4297-a559-073421c6051bn%40googlegroups.com.


Steven Berkson

unread,
Apr 2, 2024, 8:06:10 AMApr 2
to joomla-de...@googlegroups.com

Do you have Associations enabled in Joomla? If you disable the “language filter” plugin, does the problem go away?

--

Steven Berkson

unread,
Apr 2, 2024, 12:55:38 PMApr 2
to joomla-de...@googlegroups.com

Wouldn’t that be modifying a core file? Is this a bug in the core files, or something wrong with the implementation of com_associations?

Yann

unread,
Apr 2, 2024, 1:21:03 PMApr 2
to Joomla! General Development
Thank you for your answers.

@seraphim
the change
if (!\array_key_exists('title', $type ?? '')) {
generate an error : "array_key_exists(): Argument #2 ($array) must be of type array, string given"
To solve the problem, I can comment this test, but I don't want to modify a Joomla file that may be replaced in the next update.


@Neo314
Yes it's a multi lang website.
So the plugin "System - Language Filter" and "System - Language Code" are enabled.
For the test, I deactivated these plugins and category editing worked again, without error.
I went further and tested the different options, and it's the option "Item Associations" that's the problem.

Maciek Wołpiuk

unread,
Apr 5, 2024, 6:50:15 AMApr 5
to joomla-de...@googlegroups.com
Hello

Problem is in line -> $type = $this->getType($typeName);

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

$type must be array but its null;

Try to var_dump($type) or put
if (is_array( $type)) {
......
}else{
return '';
}

Pozdr
Maciek


Nie zawiera wirusów.www.avast.com

Reply all
Reply to author
Forward
0 new messages