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

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

Merged
merged 6 commits into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions administrator/components/com_fields/src/Helper/FieldsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,24 +485,14 @@ public static function prepareForm($context, Form $form, $data)
// Loading the XML fields string into the form
$form->load($xml->saveXML());

$model = Factory::getApplication()->bootComponent('com_fields')
->getMVCFactory()->createModel('Field', 'Administrator', ['ignore_request' => true]);

if (
(!isset($data->id) || !$data->id) && Factory::getApplication()->getInput()->getCmd('controller') == 'modules'
&& Factory::getApplication()->isClient('site')
) {
// Modules on front end editing don't have data and an id set
$data->id = Factory::getApplication()->getInput()->getInt('id');
}

// Looping through the fields again to set the value
if (!isset($data->id) || !$data->id) {
return true;
}

foreach ($fields as $field) {
$value = $model->getFieldValue($field->id, $data->id);
// Get the value already loaded by static::getFields()
$value = $field->rawvalue;

if ($value === null) {
continue;
Expand Down