Language Change NPM Resource Changed PR-5.4-dev Pending

User tests: Successful: Unsuccessful:

avatar sshekhar563
sshekhar563
7 Nov 2025

Fixes #46369

This PR restores the caching and data-loading behavior that was lost when
the getInstance() methods were removed from the core classes.

Changes

  • FormFactory

    • Added static caching for form instances (private static array $forms)
    • Automatically loads XML form data (string or file)
    • Introduced clearCache() for tests/runtime reloads
  • UserFactory

    • Added static caching for user instances (private static array $cache)
    • Reuses cached users by ID or username to avoid duplicate DB queries
    • Introduced clearCache() for testing and runtime reloads

Benefits

  • Restores performance and behavior parity with the old Form::getInstance()
    and User::getInstance() implementations.
  • Prevents code duplication and performance regression.
  • Fully backward-compatible and consistent with Joomla 6 architecture.

Testing Instructions

  1. Call FormFactory::createForm() multiple times with the same name — ✅ should return the same instance.
  2. Call UserFactory::loadUserById() or loadUserByUsername() repeatedly — ✅ should only query DB once.
  3. Confirm no regressions occur in form handling or user loading.
avatar sshekhar563 sshekhar563 - open - 7 Nov 2025
avatar sshekhar563 sshekhar563 - change - 7 Nov 2025
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 7 Nov 2025
Category Libraries
avatar laoneo
laoneo - comment - 7 Nov 2025

Please create a new caching factory. This here is a bc break. That's why we intended interfaces to abstract different logic.

avatar sshekhar563 sshekhar563 - change - 8 Nov 2025
Labels Added: PR-5.4-dev
avatar richard67
richard67 - comment - 8 Nov 2025

Please create a new caching factory. This here is a bc break. That's why we intended interfaces to abstract different logic.

@sshekhar563 Do I assume right that you latest refactoring has implemented @laoneo 's suggestion?

@laoneo Could you check and report back if it's ok now?

avatar richard67 richard67 - change - 8 Nov 2025
Title
fix: restore caching and data loading in FormFactory and UserFactory (#46369)
[5.4] Fix: Restore caching and data loading in FormFactory and UserFactory (#46369)
avatar richard67 richard67 - edited - 8 Nov 2025
avatar richard67
richard67 - comment - 8 Nov 2025

@sshekhar563 Sorry, but your last commit was wrong. Why are you changing the indentation from spaces to tabulators in the FormFactory.php and UserFactory.php file? If you simply had applied my change suggestions instead of force-pushing a wrong change, it would be ok now.

avatar joomla-cms-bot joomla-cms-bot - change - 8 Nov 2025
Category Libraries Repository SQL Administration com_admin Postgresql com_config Language & Strings NPM Change
avatar richard67
richard67 - comment - 8 Nov 2025

@sshekhar563 Please check your changes on GitHub! You are changing 37 files. Please stop to force push your changes. Do normal pushes. Or if you can't handle it, close this PR and open a new one.

avatar sshekhar563
sshekhar563 - comment - 8 Nov 2025

Hi @richard67

Thank you for the feedback and for pointing this out 🙏
I understand that my current branch has too many unintended file changes due to line-ending normalization and previous force pushes.

I’ll be closing this PR and creating a new clean one soon, based on the latest 5.4-dev branch, which will include only the relevant files (FormFactory, UserFactory, and their new caching factories).

The new PR will be PHPCS-compliant and have a clean commit history for easier review.

Thanks again for your patience and guidance I really appreciate your help while I’m learning the contribution process. 🙏

avatar sshekhar563 sshekhar563 - change - 8 Nov 2025
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2025-11-08 12:51:13
Closed_By sshekhar563
Labels Added: Language Change NPM Resource Changed
avatar sshekhar563 sshekhar563 - close - 8 Nov 2025
avatar richard67
richard67 - comment - 8 Nov 2025

@sshekhar563 When you have created the new PR, please post here a comment with a reference to that PR so interested readers can follow the previous discussions. Thanks in advance, and have success with the new PR.

avatar sshekhar563
sshekhar563 - comment - 9 Nov 2025

Hi @richard67

This PR (#46428) replaces #46420 with a clean, PHPCS-compliant version based on 5.4-dev.
It includes only the intended factory changes and follows all previous feedback.

Thanks for help and guidance

Add a Comment

Login with GitHub to post a comment