? Pending

User tests: Successful: Unsuccessful:

avatar continga
continga
3 Sep 2019

Pull Request for Issue #24782

Summary of Changes

The problem is that we were passing $section to the category service, which always ends up bailing with a SectionNotFoundException - while we just wanted to get all categories at this point.

It basically reverts the change made to this line in commit c778973 but that is a merge commit
and none of the merged parents have that change, and the commit does not give an explanation why
that change is needed. It is not needed at all from my point of view, so reverting it here.

This fixes #24782 and should not have any side effects, as the CategoryService is being instanciated
with a correct context (the component), so passing the $section is not needed. We want all categories.

Testing Instructions

Try to create a new Custom Field in e.g. the Content group.

Expected result

You should be able to set a category for that field on the right hand side.

Actual result

Without this change, you are not able to set a category.

Additional info

Poking @wilsonge You are the author of the original commit creating the problem, do you remember why you changed that line, and are you OK with this PR changing it back, or do you see any problems?

avatar continga continga - open - 3 Sep 2019
avatar continga continga - change - 3 Sep 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 3 Sep 2019
Category Administration com_fields
avatar franz-wohlkoenig franz-wohlkoenig - change - 4 Sep 2019
Title
Fix issue #24782
[4.0] Fix Category select is missing/broken for fields
avatar franz-wohlkoenig franz-wohlkoenig - edited - 4 Sep 2019
avatar SharkyKZ
SharkyKZ - comment - 4 Sep 2019

Categories support different content types (sections) per component (See #17769). So I don't think this is correct. Looks like Category services in components need to be updated to include the section. Either that or we should try to load categories with and without the section before failing.

avatar wilsonge
wilsonge - comment - 4 Sep 2019

@SharkyKZ got it. it was an attempted port of the PR he mentions. I definitely might have made a mess of it in the conflicts though

avatar continga continga - change - 4 Sep 2019
Labels Added: ?
avatar continga
continga - comment - 4 Sep 2019

Okay, I have changed my PR to first check on component+section, and if that hasn't been found, only then search for just the component. Can you please take a look again @SharkyKZ and @wilsonge ?

Additionally, I noticed the following: Looking at the changes made in #17769, I see that in the FieldsModel, we are still using the (old?) Categories instance:

$cat = Categories::getInstance(str_replace('com_', '', $parts[0]) . '.' . $parts[1]);

Same for the fields default template:

$category = Categories::getInstance(str_replace('com_', '', $component) . '.' . $section);

I am wondering why we then are using the (new?) ComponentObject only for the FieldModel:

$cat = $componentObject->getCategory([], $section ?: '');

Maybe we should switch the other two cases to be using the (new?) ComponentObject too, or maybe switch the FieldModel to use the (old?) Categories instance? Instead of now having 2 different ways of doing the same thing in the same component...

avatar wilsonge
wilsonge - comment - 8 Sep 2019

Maybe we should switch the other two cases to be using the (new?) ComponentObject too, or maybe switch the FieldModel to use the (old?) Categories instance? Instead of now having 2 different ways of doing the same thing in the same component...

Yup it should be swapped over to be consistently using component objects

avatar wilsonge
wilsonge - comment - 8 Sep 2019

Also something seems weird here. If section doesn't exist it should be able to handle the empty string fine - because it is the default parameter https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Categories/CategoryServiceTrait.php#L43

avatar wilsonge wilsonge - change - 28 Sep 2019
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2019-09-28 03:30:15
Closed_By wilsonge
avatar wilsonge wilsonge - close - 28 Sep 2019
avatar wilsonge wilsonge - merge - 28 Sep 2019
avatar wilsonge
wilsonge - comment - 28 Sep 2019

Spent some time debugging to understand. Apparently article comes back as a valid section which is kinda stupid. But it's a much riskier b/c affecting change to try and fix that so this will do. Thanks!

Add a Comment

Login with GitHub to post a comment