DefaultAssignmentChecker error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • a.slyzhko
    Member
    • Oct 2023
    • 90

    DefaultAssignmentChecker error

    Hi! I have noticed strange thing, when assigning a user to any entity. I'm testing my application with user with team assignment rights. And I get the followind error after clicking Save button.
    HTML Code:
    ERROR: Slim Application Error Type: TypeError Code: 0 Message: Espo\Repositories\User::checkBelongsToAnyOfTeams(): Argument #2 ($teamIds) must be of type array, null given, called in /var/www/espocrm/application/Espo/Core/Acl/DefaultAssignmentChecker.php on line 147
    When application reaches this block
    PHP Code:
    else if ($assignmentPermission === Table::LEVEL_TEAM) {
        $teamIdList = $user->get(self::ATTR_TEAMS_IDS);
            if (!$this->getUserRepository()->checkBelongsToAnyOfTeams($assignedUserId, $teamIdList)) {
                return false;
            }
    }
    Somehow, the teamIds are not being fetched from the database when the user entity is injected into the Acl of user record service. Any ideas?
    Last edited by a.slyzhko; 11-16-2023, 01:03 PM.
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Use getTeamIdList.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment


    • a.slyzhko
      a.slyzhko commented
      Editing a comment
      Thanks! Your solution is actually the same as mine. Will you replace this in the following updates?
  • a.slyzhko
    Member
    • Oct 2023
    • 90

    #3
    I resolved this issue by replacing $user->get method call
    PHP Code:
    $teamIdList = $user->get(self::ATTR_TEAMS_IDS); 
    
    with this method call
    PHP Code:
    $teamIdList = $user->getLinkMultipleIdList(self::FIELD_TEAMS); 
    
    As this is core, I think developers should replace this in the following updates.

    Comment

    • yuri
      Member
      • Mar 2014
      • 8440

      #4
      How do you create a record service?
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • a.slyzhko
        Member
        • Oct 2023
        • 90

        #5
        I'm using default one. This is PUT requst from UI. No custom logic applied
        Last edited by a.slyzhko; 11-16-2023, 01:47 PM.

        Comment

        • yuri
          Member
          • Mar 2014
          • 8440

          #6
          It's weird, as this issue should have been detected, this code is tested and it's been for years as it is. I assume it works fine on an out-of-the-box instance.

          Just want to figure out why it happens on your instance.

          This code should load teams for authenticated user: https://github.com/espocrm/espocrm/b...ation.php#L221
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment

          • a.slyzhko
            Member
            • Oct 2023
            • 90

            #7
            I'm admin and I'm logged in as regular user in incognito tab. Can this cause the issue?

            Comment

            • yuri
              Member
              • Mar 2014
              • 8440

              #8
              Yes, reproduced when logged as another user. We will need to fix both, Assignment Checker and loading teams when logged as another user.
              If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

              Comment

              • yuri
                Member
                • Mar 2014
                • 8440

                #9
                I'll fix it for v8.1. Thanks for help.
                If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                Comment


                • a.slyzhko
                  a.slyzhko commented
                  Editing a comment
                  Great! I'm glad to help. It's my pleasure.
              Working...