Current user groups are used instead of "created by" groups when they differ #5259

Open
opened 2026-02-20 16:32:06 -05:00 by deekerman · 0 comments
Owner

Originally created by @SinergiaCRM on GitHub (Oct 7, 2024).

Issue

When a record is created on behalf of a user different from the current users, groups from current user are used.
Example: when an entry point which does not require authentication creates a record setting a creator different from the user used in the entry point, the groups taken by the created record are not the ones from the creator indicated but from the user used.

Possible Fix

No response

Steps to Reproduce the Issue

1.Create an entry-point which does not require authentication, sets its user to system user and create a record
`
<?php
if (!defined('sugarEntry') || !sugarEntry) {
    die('Not A Valid Entry Point');
}

global $current_user;
$current_user->getSystemUser();

$bean = BeanFactory::newBean('Contacts');
$bean->first_name = 'Test';
$bean->last_name = 'EP1';
$bean->set_created_by = false;
$bean->created_by = 'XXXXX-XXXXX-XXXXX'; // ID of a different user with different groups
$bean->save();
`
2.Check that the created record has the system user groups instead of the groups from the user indicated.

Context

No response

Version

7

What browser are you currently using?

Chrome

Browser Version

No response

Environment Information

MAriaDB, PHP 7.4

Operating System and Version

Debian

Originally created by @SinergiaCRM on GitHub (Oct 7, 2024). ### Issue When a record is created on behalf of a user different from the current users, groups from current user are used. Example: when an entry point which does not require authentication creates a record setting a creator different from the user used in the entry point, the groups taken by the created record are not the ones from the creator indicated but from the user used. ### Possible Fix _No response_ ### Steps to Reproduce the Issue ```bash 1.Create an entry-point which does not require authentication, sets its user to system user and create a record ` <?php if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } global $current_user; $current_user->getSystemUser(); $bean = BeanFactory::newBean('Contacts'); $bean->first_name = 'Test'; $bean->last_name = 'EP1'; $bean->set_created_by = false; $bean->created_by = 'XXXXX-XXXXX-XXXXX'; // ID of a different user with different groups $bean->save(); ` 2.Check that the created record has the system user groups instead of the groups from the user indicated. ``` ### Context _No response_ ### Version 7 ### What browser are you currently using? Chrome ### Browser Version _No response_ ### Environment Information MAriaDB, PHP 7.4 ### Operating System and Version Debian
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#5259
No description provided.