ACSD-47027: slow query B2B CompanyRole GraphQL update
- Topics:
- B2B
- Companies
- GraphQL
- Roles/Permissions
CREATED FOR:
- Experienced
- Admin
The ACSD-47027 patch solves the issue where the slow query B2B CompanyRole GraphQL update does not work as expected. This patch is available when the Quality Patches Tool (QPT) 1.1.23 is installed. The patch ID is ACSD-47027. Please note that the issue is scheduled to be fixed in Adobe Commerce 2.4.6.
Affected products and versions
The patch is created for Adobe Commerce version:
- Adobe Commerce (all deployment methods) 2.4.2-p1
Compatible with Adobe Commerce versions:
- Adobe Commerce (all deployment methods) 2.4.2 - 2.4.5-p1
magento/quality-patches
package to the latest version and check the compatibility on the Quality Patches Tool: Search for patches page. Use the patch ID as a search keyword to locate the patch.Issue
The slow query B2B CompanyRole GraphQL update does not work as expected.
Prerequisites:
Install the B2B module.
Steps to reproduce:
-
In the Adobe Commerce Admin, go to Stores > Settings > Configurations > B2B Features and set Enable Company to Yes.
-
Go to the frontend and create a company.
-
After you log in as a company user, go to My Account > Roles and Permissions and add a new role.
-
Enable dev query log using
bin/magento dev:que:enab
. -
Now send the below GraphQL request (id is the base64 encoded role id):
mutation { updateCompanyRole( input: { id: "Mg==" permissions: [ "Magento_Company::view" "Magento_Company::view_account" "Magento_Company::user_management" "Magento_Company::roles_view" ] } ) { role { id name permissions { id text children { id text children { id text } } } }
-
Check the query log.
-
You can see that the above query is executed. This query is executed in
app/code/Magento/CompanyGraphQl/Model/Company/Role/ValidateRole.php::validateResources
.
Expected results:
The app/code/Magento/CompanyGraphQl/Model/Company/Role/ValidateRole.php::validateResources
needs to be optimized to avoid loading all the data available in the company_permissions DB table.
Actual results:
Adobe Commerce executes a query without any filter. When there are a large number of records, it takes a lot of time for Adobe Commerce to prepare the data collection.
Apply the patch
To apply individual patches, use the following links depending on your deployment method:
- Adobe Commerce or Magento Open Source on-premises: Quality Patches Tool > Usage in the Quality Patches Tool guide.
- Adobe Commerce on cloud infrastructure: Upgrades and Patches > Apply Patches in the Commerce on Cloud Infrastructure guide.
Related reading
To learn more about Quality Patches Tool, refer to:
- Quality Patches Tool released: a new tool to self-serve quality patches in the support knowledge base.
- Check if patch is available for your Adobe Commerce issue using Quality Patches Tool in the Quality Patches Tool guide.
For info about other patches available in QPT, refer to Quality Patches Tool: Search for patches in the Quality Patches Tool guide.