Skip to content

$db->loadObjectList('id', MenuItem::class) fails on Unknown fetch type '8' #254

@mahagr

Description

@mahagr

Steps to reproduce the issue

This example needs Joomla, see issue joomla/joomla-cms#35452

use Joomla\CMS\Menu\MenuItem;

$db = \JFactory::getDbo();
$query = $db->getQuery(true)
    ->select('m.id, m.menutype, m.title, m.alias, m.note, m.path AS route, m.link, m.type, m.level, m.language')
    ->select($db->quoteName('m.browserNav') . ', m.access, m.params, m.home, m.img, m.template_style_id, m.component_id, m.parent_id')
    ->select('e.element as component')
    ->from('#__menu AS m')
    ->join('LEFT', '#__extensions AS e ON m.component_id = e.extension_id')
    ->where('m.menutype = ' . $db->quote($menutype))
    ->where('m.parent_id > 0')
    ->where('m.client_id = 0')
    ->where('m.published >= 0')
    ->order('m.lft');

// Set the query
$db->setQuery($query);

$list = $db->loadObjectList('id', MenuItem::class);

Expected result

The query should work just as it worked in Joomla 3.9/3.10.

Actual result

Exception: Unknown fetch type '8'. This seems to happen when using mysqli but not when using dbo.

Type 8 is same as FetchMode::CUSTOM_OBJECT .

System information (as much as possible)

PHP 8.0.10 / 7.4.23

Additional comments

Following workaround works (replace the last line):

$list = [];
foreach ($db->loadAssocList('id') as $id => $data) {
    $list[$id] = new MenuItem($data);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions