Skip to content

Conversation

@froozeify
Copy link
Member

@froozeify froozeify commented Nov 3, 2025

Checklist before requesting a review

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.

Description

Creating a subentity the form will redirect the user to it , but since the user has activated an entity, he won't have access.

This PR is the implementation of my proposal number 3 : #21497 (comment)

Screenshots:

Screencast.from.2025-11-03.09-52-19.webm

@froozeify froozeify force-pushed the 11.0/21497-problem-with-entity-creation branch from f09dba6 to 1884957 Compare November 3, 2025 08:54
@froozeify froozeify marked this pull request as ready for review November 3, 2025 10:12
// Root entity cannot be deleted, so if we added an entity this means GLPI is now multi-entity
$_SESSION['glpi_multientitiesmode'] = 1;
// We force the recursivity, so the new entity is visible in the current session
Session::changeActiveEntities(Session::getActiveEntity(), true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to check that the user is allowed to see recursive content?

I think the "add entity" action is only available for users that can see recursive content anyway but I guess it doesn't hurt to check twice here?

Not a mandatory change, just wondering out loud.

Copy link
Member

Choose a reason for hiding this comment

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

IMHO, we must only add the newly created entity to the active scope. The existing hack was probably incomplete, maybe only updating one or two more session variables is enough.

// Root entity cannot be deleted, so if we added an entity this means GLPI is now multi-entity
$_SESSION['glpi_multientitiesmode'] = 1;
// We force the recursivity, so the new entity is visible in the current session
Session::changeActiveEntities(Session::getActiveEntity(), true);
Copy link
Member

Choose a reason for hiding this comment

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

IMHO, we must only add the newly created entity to the active scope. The existing hack was probably incomplete, maybe only updating one or two more session variables is enough.

@cedric-anne cedric-anne added the bug label Nov 6, 2025
@cedric-anne cedric-anne added this to the 11.0.3 milestone Nov 6, 2025
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.

Problem with entity creation

3 participants