Skip to content

[ECP-9907] Fix incompatible DB connection pattern in CreateStatusAuthorized class#3246

Merged
candemiralp merged 3 commits intomainfrom
ECP-9907
Feb 17, 2026
Merged

[ECP-9907] Fix incompatible DB connection pattern in CreateStatusAuthorized class#3246
candemiralp merged 3 commits intomainfrom
ECP-9907

Conversation

@candemiralp
Copy link
Contributor

Using the repository pattern is fragile if multi-cluster setup is used. Instead, single DB connection instance approach has been implemented for CreateStatusAuthorized migration class.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @candemiralp, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the CreateStatusAuthorized data patch to enhance its robustness and compatibility with multi-cluster environments. By transitioning from Magento's repository pattern to direct database connection methods, the patch ensures more reliable creation and assignment of the 'adyen_authorized' order status, mitigating potential issues arising from the repository's behavior in complex setups.

Highlights

  • Database Interaction Refactor: The CreateStatusAuthorized data patch was refactored to use direct database connection methods instead of Magento's repository pattern for creating and assigning the 'adyen_authorized' order status.
  • Dependency Removal: Removed dependencies on Magento\Framework\Exception\AlreadyExistsException, Magento\Sales\Model\Order\StatusFactory, and Magento\Sales\Model\ResourceModel\Order\StatusFactory.
  • Robustness Improvement: The logic for creating the order status and state now explicitly checks for existing entries before insertion, preventing AlreadyExistsException and improving reliability in multi-cluster setups.
  • Setup Connection Management: Explicitly added startSetup() and endSetup() calls to the database connection within the apply method.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • Setup/Patch/Data/CreateStatusAuthorized.php
    • Removed AlreadyExistsException, StatusFactory, and StatusResourceFactory dependencies.
    • Replaced repository-based status creation and assignment with direct database queries.
    • Implemented checks for existing status and state entries before insertion.
    • Added startSetup() and endSetup() calls for database connection management.
Activity
  • No activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request refactors the CreateStatusAuthorized data patch to use a direct database connection instead of repositories, which is a good improvement for robustness in multi-cluster environments. The implementation is mostly correct, but I've found a potential bug in how the status-state association is checked. My review includes a suggestion to fix this to ensure the patch behaves correctly in all scenarios.

@candemiralp candemiralp changed the title [ECP-9907] Use single DB connection instead of repository [ECP-9907] Fix incompatible DB connection pattern in CreateStatusAuthorized class Feb 17, 2026
@sonarqubecloud
Copy link

@candemiralp candemiralp added the Fix Indicates a bug fix label Feb 17, 2026
@candemiralp candemiralp merged commit ac47b4d into main Feb 17, 2026
9 of 11 checks passed
@candemiralp candemiralp deleted the ECP-9907 branch February 17, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix Indicates a bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants