Announcement

Collapse
No announcement yet.

DefaultAssignmentChecker error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #2
    Use getTeamIdList.

    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?

  • #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


    • #4
      How do you create a record service?

      Comment


      • #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


        • #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

          Comment


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

            Comment


            • #8
              Yes, reproduced when logged as another user. We will need to fix both, Assignment Checker and loading teams when logged as another user.

              Comment


              • #9
                I'll fix it for v8.1. Thanks for help.

                Comment


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