? Success

User tests: Successful: Unsuccessful:

avatar Bakual
Bakual
4 Jan 2018

With custom fields, we check the section part of the context if it is valid. The component can then adjust the section as needed. That is useful if the context triggered in plugin events doesn't match the field context.
If the context is unknown we usually return null in that method.
See for example the one for com_content:

public static function validateSection($section)
{
if (JFactory::getApplication()->isClient('site'))
{
// On the front end we need to map some sections
switch ($section)
{
// Editing an article
case 'form':
// Category list view
case 'featured':
case 'category':
$section = 'article';
}
}
if ($section != 'article')
{
// We don't know other sections
return null;
}
return $section;
}

I would expect if I return null, then custom fields would stop processing as the context is unknown to the component. However it just runs with the original context.

Summary of Changes

This PR changes the FieldsHelper::extract method so it returns null as well if the validate method returns null. This will stop the calling fields code.

Testing Instructions

I'm not sure how it can be really tested. I have a failure in my extension in J4 due to this, but it is a quite specific setting.
I think it should be possible to run an onContentPrepare event with a context com_content.foo and debug if com_fields tries to lookup fields (should get a query at least).

The easier way is probably to just make sure custom fields still work in Content, Contact and 3rd parties.

Documentation Changes Required

No

@laoneo What do you think?
As a background I got an issue with the current code when I try categories with sections (with #17769 applied already) and an unknown context is passed.

avatar Bakual Bakual - open - 4 Jan 2018
avatar Bakual Bakual - change - 4 Jan 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 4 Jan 2018
Category Administration com_fields
avatar Bakual Bakual - close - 6 Oct 2021
avatar Bakual Bakual - change - 6 Oct 2021
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2021-10-06 19:33:30
Closed_By Bakual
Labels Added: ?
Removed: ?

Add a Comment

Login with GitHub to post a comment