Skip to content

[5.4] check if state is initialized in content CategoryModel#46316

Merged
richard67 merged 2 commits intojoomla:5.4-devfrom
heelc29:issue-46311
Oct 19, 2025
Merged

[5.4] check if state is initialized in content CategoryModel#46316
richard67 merged 2 commits intojoomla:5.4-devfrom
heelc29:issue-46311

Conversation

@heelc29
Copy link
Contributor

@heelc29 heelc29 commented Oct 18, 2025

Pull Request for Issue #46311 .

Summary of Changes

Check if model state is initialized before access
This is regression from PR #45704

Testing Instructions

Follow issue description or add following code to components\com_content\tmpl\featured\default.php

$app   = \Joomla\CMS\Factory::getApplication();
$model = $app->bootComponent('com_content')->getMVCFactory()
    ->createModel('Category', 'Site', ['ignore_request' => false]);
$category = $model->getCategory();
var_dump($category::class);

Actual result BEFORE applying this Pull Request

Exception
image

Expected result AFTER applying this Pull Request

Should work again (like J5.3)
image

Link to documentations

Please select:

  • No documentation changes for docs.joomla.org needed
  • No documentation changes for manual.joomla.org needed

@chmst
Copy link
Contributor

chmst commented Oct 18, 2025

Both codes work, so I give a successful test. I would keep the old-fashioned variant, it is easier to read. This model will be often read by extension developers who are not familiar with newest PHP syntax. If the new variant is used, a comment could be helpful.

@chmst
Copy link
Contributor

chmst commented Oct 18, 2025

I have tested this item ✅ successfully on 8c8290d


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46316.

@joomdonation
Copy link
Contributor

I have tested this item ✅ successfully on b8a1198


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46316.

@joomdonation
Copy link
Contributor

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46316.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Oct 19, 2025
@richard67 richard67 added this to the Joomla! 5.4.1 milestone Oct 19, 2025
@richard67 richard67 merged commit 9272ce1 into joomla:5.4-dev Oct 19, 2025
41 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Oct 19, 2025
@richard67
Copy link
Member

Thanks @heelc29 for the fix, and @chmst and @joomdonation for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants