In Joomla 4, the following works:
$modelcat = new Joomla\Component\Content\Site\Model\CategoryModel();
$category = $modelcat->getCategory();
In Joomla 5, it crashes with the error "Uncaught Throwable of type Error thrown with message "Call to a member function get() on null"". The exception is thrown in CategoryModel::getCategory() on components/com_content/src/Model/CategoryModel.php:338:
if (!empty($this->state->get('params'))) {
because the "state" data member is null out of the CategoryModel constructor. It worked in Joomla 4 because the corresponding line in getCategory would go instead:
if (isset($this->state->params)) {
and isset would return false if state is null.
Observed on the JA Playschool template by JoomlArt, with a menu item of type "Gallery List". Reproduces on a fresh install.
| Labels |
Removed:
?
|
||
| Labels |
Added:
No Code Attached Yet
|
||
| Status | New | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2025-10-28 14:48:24 |
| Closed_By | ⇒ | sevaa |
Thanks. Closing as duplicate.
Hi Seva, this issue has already been reported #46311 and should fixed with #46316. It will be included in the next releases 5.4.1/6.0.1