Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from

Conversation

Fedik
Copy link
Member

@Fedik Fedik commented Feb 25, 2024

Summary of Changes

The same as #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:
  • No documentation changes for docs.joomla.org needed
  • Pull Request link for manual.joomla.org:
  • No documentation changes for manual.joomla.org needed

@Fedik Fedik added the bug label Feb 25, 2024
@Fedik Fedik changed the title [4.4] Get the field value already loaded by getFields() [4.4] Fix of unnecessary SQL query for Fields, get the field value already loaded by getFields() Feb 25, 2024
@richard67
Copy link
Member

@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.

@laoneo
Copy link
Member

laoneo commented Feb 25, 2024

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.

@Fedik
Copy link
Member Author

Fedik commented Feb 25, 2024

Nope

foreach ($fields as $key => $original) {
/*
* Doing a clone, otherwise fields for different items will
* always reference to the same object
*/
$field = clone $original;

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

@ceford
Copy link
Contributor

ceford commented Feb 26, 2024

I have tested this item ✅ successfully on e5e307b


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

1 similar comment
@chmst
Copy link
Contributor

chmst commented Feb 26, 2024

I have tested this item ✅ successfully on e5e307b


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

@chmst
Copy link
Contributor

chmst commented Feb 26, 2024

RTC


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

@richard67
Copy link
Member

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Feb 26, 2024
@laoneo laoneo added the RMDQ ReleaseManagerDecisionQueue label Mar 4, 2024
@Fedik Fedik closed this Mar 7, 2024
@Fedik Fedik deleted the fields-fix2 branch March 7, 2024 09:13
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug PR-4.4-dev RMDQ ReleaseManagerDecisionQueue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants