PR-6.2-dev Architecture Pending

User tests: Successful: Unsuccessful:

avatar joomdonation
joomdonation
25 Apr 2026

Pull Request resolves # .

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

The SiteApplication, AdministratorApplication, and ApiApplication all called $this->loadDocument() without passing $document argument, causing an internal fallback to the deprecated method Factory::getDocument() call.

This PR introduces createDocument() method on CMSApplication to create document object which bring the following improvements:

  • Use dependencies (language, document factory) which are necessary to create document directly from the application rather than the static Factory.
  • Avoid calling deprecated method Factory::getDocument() which was planned to remove in Joomla 7
  • Consistent with how language is created and injected into application

Testing Instructions

  • Use Joomla 6.2 (Joomla 6.1 is also OK)
  • Apply patch, and access to random pages from frontend and backend of your site. If you are familiar with web services, try to execute a request with web service, too

Actual result BEFORE applying this Pull Request

Works. But use deprecated code for creating document object for application

Expected result AFTER applying this Pull Request

Works without using deprecated code for creating document object for application

Link to documentations

Please select:

  • No documentation changes for guide.joomla.org needed
  • No documentation changes for manual.joomla.org needed
avatar joomdonation joomdonation - open - 25 Apr 2026
avatar joomdonation joomdonation - change - 25 Apr 2026
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 25 Apr 2026
Category Libraries
avatar joomdonation joomdonation - change - 25 Apr 2026
Labels Added: PR-6.2-dev
avatar joomdonation joomdonation - change - 18 Jun 2026
Labels Added: Architecture
avatar joomla-cms-bot joomla-cms-bot - change - 20 Jun 2026
Category Libraries Installation Libraries
bf22b77 20 Jun 2026 avatar joomdonation CS
avatar joomla-cms-bot joomla-cms-bot - change - 20 Jun 2026
Category Libraries Installation Libraries
avatar HLeithner
HLeithner - comment - 24 Jun 2026

I would suggest change the Factory::getDocument() and Factory::createDocument() to use the "new application" methods, so we have only one location where a document is created.

Additionally I would move createDocument() to WebApplication and also move the loadDocument change to the WebApplication.

Additonally wrap all Factory::$document = $document code into the "b/c plugin switch" COMPAT_JOOMLA_7.

reference: #47911

and I think move it to 7.0

avatar laoneo
laoneo - comment - 24 Jun 2026

I would not make the createDocument function in the application class public. But I do agree that the factory should use the document from the app and not vice versa. Therefore we can remove createDocument in the Factory and route getDocument in factory to the app.

avatar joomdonation
joomdonation - comment - 25 Jun 2026

Thanks for the feedback. Below are details response:

I would suggest change the Factory::getDocument() and Factory::createDocument() to use the "new application" methods, so we have only one location where a document is created.

This is not safe. The "new application" needs language available in application to create document. That is only available after application Initialise phase. So if someone calls Factory::getDocument() before that for whatever reason, it will be broken.

Additionally I would move createDocument() to WebApplication and also move the loadDocument change to the WebApplication.

This is not possible because WebApplication does not have container injected, so we do not have necessary services to create documents there.

I would not make the createDocument function in the application class public

Yes, that could not be public because it can only be used at certain phase in application life cycle. It is protected on purpose and can only be used internal for now.

Add a Comment

Login with GitHub to post a comment