joomla-cms icon indicating copy to clipboard operation
joomla-cms copied to clipboard

[4.4] Fix of unnecessary SQL query for Fields, get the field value already loaded by getFields()

Open Fedik opened this issue 11 months ago • 3 comments

Summary of Changes

The same as https://github.com/joomla/joomla-cms/pull/42861 but for j4

Remove unnecessary SQL query for the custom fields, during the form rendering. FieldsHelper::getFields() load the field value, however FieldsHelper::prepareForm() also loading them wthout a reason. Also removed some dead code.

Testing Instructions

Enable debug and debug query. Create a couple of Custom fields, let say 10. Open article editing.

Actual result BEFORE applying this Pull Request

Notice amount of query in debug. Let say 75

Expected result AFTER applying this Pull Request

The amount of query will be 10 less, 65

Link to documentations

Please select:

  • [ ] Documentation link for docs.joomla.org:
  • [x] No documentation changes for docs.joomla.org needed
  • [ ] Pull Request link for manual.joomla.org:
  • [x] No documentation changes for manual.joomla.org needed

Fedik avatar Feb 25 '24 12:02 Fedik

@crommie @chmst @adj9 As you had tested PR #42861 , could you test this one here, too? It's the same as the other one, just for 4.4 instead of 5.1. Thanks in advance.

richard67 avatar Feb 25 '24 12:02 richard67

Does this also work when you fetch two articles within the same request. Pretty sure the second article gets the same rawvalue as the first one.

laoneo avatar Feb 25 '24 15:02 laoneo

Nope https://github.com/joomla/joomla-cms/blob/d272577bbbc636284305538e2d76ba48a7a6b933/administrator/components/com_fields/src/Helper/FieldsHelper.php#L179-L185

Every time you call FieldsHelper::getFields it will load new values.

Fedik avatar Feb 25 '24 15:02 Fedik

I have tested this item :white_check_mark: successfully on e5e307bf2d0cd4b914ebfa130c7c25811d35ad60


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

ceford avatar Feb 26 '24 13:02 ceford

I have tested this item :white_check_mark: successfully on e5e307bf2d0cd4b914ebfa130c7c25811d35ad60


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

chmst avatar Feb 26 '24 15:02 chmst

RTC


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

chmst avatar Feb 26 '24 15:02 chmst

RTC


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

richard67 avatar Feb 26 '24 15:02 richard67