Skip to content

[5.0] Rework session/application DIC to avoid circular dependencies#36499

Merged
HLeithner merged 8 commits intojoomla:5.0-devfrom
wilsonge:feature/fix-circular-dependencies
Jul 12, 2023
Merged

[5.0] Rework session/application DIC to avoid circular dependencies#36499
HLeithner merged 8 commits intojoomla:5.0-devfrom
wilsonge:feature/fix-circular-dependencies

Conversation

@wilsonge
Copy link
Copy Markdown
Contributor

@wilsonge wilsonge commented Dec 31, 2021

Summary of Changes

This is a semi-major rework of the application and session packages to avoid the circular dependencies between the two. As an unideal compromise the request object (i.e. JInput) is created as an explicit resource into the container as it's the main common dependency the two rely on. It's not very architectural best practice - but it's how symfony worked until very recently and it's also how laravel still works - so it's not super terrible compared to global statics :)

Testing Instructions

Test all 5 main applications in Joomla - Console, Site, Admin, API and Installation. Ensure that they are available and work properly. Ensure that session works, by logging in and anything else that uses the session heavily (e.g. mod_logged in the backend).

Obviously with this being a change to two of the lowest level pieces of the stack it's hard to predict how it would manifest beyond the major breaks (exceptions etc). So I'm somewhat relying on people testing carefully!

Someone who understands the finesee's of cookies better than me - I'd also appreciate a review of the cookiePath parts of JoomlaStorage - as before sometimes the cookiePath was an empty string and sometimes '/' and i'm not 100% sure if there's a difference or not. There might be a difference in the administrator directory - depending on exactly the path is determined? (PHP Reference for those brave enough) https://www.php.net/manual/en/function.setcookie.php

Documentation Changes Required

None

@wilsonge wilsonge force-pushed the feature/fix-circular-dependencies branch from 3a734a7 to 54633db Compare December 31, 2021 02:55
@richard67
Copy link
Copy Markdown
Member

What is a DIC? I hope it’s not a typo and the K is missing 😄

@brianteeman
Copy link
Copy Markdown
Contributor

Dependency Injection Container

@richard67
Copy link
Copy Markdown
Member

Ah, thanks.

@richard67
Copy link
Copy Markdown
Member

@wilsonge API tests are failing, and it could be related to your changes because it complains about something with the input filter: https://ci.joomla.org/joomla/joomla-cms/49850/1/28

@wilsonge
Copy link
Copy Markdown
Contributor Author

Yup that would be me doing stupid things.

@wilsonge wilsonge changed the base branch from 4.1-dev to 4.2-dev April 29, 2022 14:12
@wilsonge wilsonge changed the title [4.1] Rework session/application DIC to avoid circular dependencies [4.2] Rework session/application DIC to avoid circular dependencies Apr 29, 2022
@Quy Quy removed the PR-4.1-dev label Apr 29, 2022
wilsonge added 2 commits June 21, 2022 13:41
This is a semi-major rework of the application and session packages to avoid the circular dependencies between the two. As an unideal compromise the request object (i.e. JInput) is created as an explicit resource into the container as it's the main common dependency the two rely on.

Test all 5 main applications in Joomla - Console, Site, Admin, API and Installation. Ensure that they are available and work properly. Ensure that session works, by logging in and anything else that uses the session heavily (e.g. mod_logged in the backend).

Obviously with this being a change to two of the lowest level pieces of the stack it's hard to predict how it would manifest beyond the major breaks (exceptions etc). So I'm somewhat relying on people testing carefully!

None
@wilsonge wilsonge force-pushed the feature/fix-circular-dependencies branch from 01d7337 to f9cd69a Compare June 21, 2022 12:47
@wilsonge wilsonge requested a review from laoneo as a code owner June 21, 2022 12:47
@joomla-bot
Copy link
Copy Markdown
Contributor

This pull requests has been automatically converted to the PSR-12 coding standard.

@wilsonge wilsonge changed the base branch from 4.2-dev to 4.3-dev August 26, 2022 20:02
@wilsonge wilsonge changed the title [4.2] Rework session/application DIC to avoid circular dependencies [4.3] Rework session/application DIC to avoid circular dependencies Aug 26, 2022
@wilsonge
Copy link
Copy Markdown
Contributor Author

wilsonge commented Sep 8, 2022

@HLeithner please can you review this and merge so it's in early in the 4.3 lifecycle. the sooner it's in the better given the b/c impact should be 0 as this all happens before even system plugins are booted

@Quy Quy removed the PR-4.2-dev label Sep 8, 2022
@HLeithner
Copy link
Copy Markdown
Member

Is there any possible b/c break if you have your own applicaton?

@HLeithner HLeithner removed the psr12 label Oct 23, 2022
@HLeithner
Copy link
Copy Markdown
Member

@wilsonge is this needed for 4.4? I think we are better safe with 5.0, since it's released at the same time it's only a matter of will it break with later php versions.

if ok please rebase on 5.0 then I add it to my personal tasks list

@wilsonge
Copy link
Copy Markdown
Contributor Author

I really don't mind where you merge it. But I'm not rebasing this for a 4th minor version in a row without some assurances that it's going to get at least tested. Because it's just a waste of my time.

@obuisard obuisard changed the title [4.3] Rework session/application DIC to avoid circular dependencies [5.0] Rework session/application DIC to avoid circular dependencies Jun 2, 2023
@obuisard obuisard changed the base branch from 4.3-dev to 5.0-dev June 9, 2023 13:54
@HLeithner
Copy link
Copy Markdown
Member

If I see it right then this shouldn't be a b/c issue, in this case I would like to merge it in 5.0

@HLeithner
Copy link
Copy Markdown
Member

can you write a migration guide / what have changed for http://pr-28.manual.joomlacode.org/migrations/44-50/removed-backward-incompatibility against the 5.0 branch please? Then I can merge this and 3rd party could adapter there code if needed

@wilsonge
Copy link
Copy Markdown
Contributor Author

See linked PR

@HLeithner HLeithner merged commit 84776fb into joomla:5.0-dev Jul 12, 2023
@HLeithner
Copy link
Copy Markdown
Member

Thanks, I merge this for the next Alpha to get more feedback.

@HLeithner HLeithner added this to the Joomla! 5.0 milestone Jul 12, 2023
@wilsonge wilsonge deleted the feature/fix-circular-dependencies branch July 12, 2023 09:20
@nikosdion
Copy link
Copy Markdown
Contributor

FWIW, even though George calls this a non ideal compromise, it's actually how I have done things in AWF for the same reason. It also makes testing far easier since we can mock the input without having to mock the entire application. So, yay, thank you for doing this!

brianteeman added a commit to brianteeman/joomla-cms that referenced this pull request Jul 15, 2023
Simple PR to correct some comments and copyright date from @wilsonge joomla#36499
wilsonge pushed a commit that referenced this pull request Jul 16, 2023
Simple PR to correct some comments and copyright date from @wilsonge #36499
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants