User tests: Successful: Unsuccessful:
Pull Request resolves #46369.
Addresses the caching concerns raised in #46369 regarding the removal of getInstance() methods, following the approach suggested by @HLeithner in the review of PR #46428.
1. Subform Registry in Form class (libraries/src/Form/Form.php)
$subforms property to hold cached child Form instances within the parent form contextgetSubForm(), setSubForm(), hasSubForm(), and clearSubForms() methods2. SubformField integration (libraries/src/Form/Field/SubformField.php)
loadSubForm() now checks the parent form's subform registry before calling Form::getInstance()loadSubFormData() similarly uses the registry for per-row subform instances3. Per-request user caching in UserFactory (libraries/src/User/UserFactory.php)
$cacheById and $cacheByUsername) using protected propertiesloadUserById() returns cached User instance if already loaded during current requestloadUserByUsername() benefits from the same cacheclearCache() method for explicit cache invalidation!empty($user->id))FormFactory::createForm() creates a new Form instance every time, no caching — causes repeated XML parsing for the same subform sourceUserFactory::loadUserById() creates a new User instance and performs a DB query every time — causes repeated DB queries for the same user within a single requestSubformField are cached in the parent Form's subform registry and reused within the same form contextUserFactory — subsequent calls for the same user ID return the cached instance without a DB queryPlease select:
Documentation link for guide.joomla.org:
No documentation changes for guide.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
| Status | New | ⇒ | Pending |
| Category | ⇒ | Libraries |
| Labels |
Added:
PR-6.2-dev
|
||
Thanks @richard67! All feedback addressed:
@since 6.2.0 with __DEPLOY_VERSION__ across both Form.php and UserFactory.php= signs in loadUserById() and clearCache()
There was a reason that you were given a template to complete when you submitted your PR. Please update the pr description accordingly. You can find the template here https://github.com/joomla/joomla-cms/blob/6.2-dev/.github/PULL_REQUEST_TEMPLATE.md