Skip to content

[4.0] Ensure the CMSApplications do always have an identity#19766

Merged
wilsonge merged 8 commits intojoomla:4.0-devfrom
Digital-Peak:j4/fix/identity
Feb 25, 2018
Merged

[4.0] Ensure the CMSApplications do always have an identity#19766
wilsonge merged 8 commits intojoomla:4.0-devfrom
Digital-Peak:j4/fix/identity

Conversation

@laoneo
Copy link
Member

@laoneo laoneo commented Feb 23, 2018

Summary of Changes

The CMSApplications needs always an identity.

Testing Instructions

  • Create a "Site Configuration Options" menu item
  • Open the menu item in the front end

Expected result

  • It opens normally when you are logged in and do have super admin permissions.
  • It throws an no access exception when you are a guest.

Actual result

The following error is thrown:

Call to a member function authorise() on null

// Ensure the identity is loaded
if (!$this->getIdentity())
{
$this->loadIdentity(Factory::getUser());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in the after session start event handler. This will arbitrarily trigger $session->start() if it hasn't been called before this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is that handler?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The afterSessionStart method until we get that properly abstracted out of the application class chain.

// Ensure the identity is loaded
if (!$this->getIdentity())
{
$this->loadIdentity(Factory::getUser());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now you can just do $session->get('user'); and all is well (otherwise you're just going through a chain of 3 or 4 method calls to get the same session object you have 10 lines above).

@dneukirchen
Copy link
Contributor

I have tested this item ✅ successfully on eae680d


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19766.

@wilsonge wilsonge merged commit 714ffa3 into joomla:4.0-dev Feb 25, 2018
@wilsonge wilsonge deleted the j4/fix/identity branch February 25, 2018 17:25
@zero-24 zero-24 added this to the Joomla 4.0 milestone Feb 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants