Conversation
This PR has been generated automatically. For more details see [upmerge_pr.yaml](/Sylius/Sylius/blob/1.13/.github/workflows/upmerge_pr.yaml). **Remember!** The upmerge should always be merged with using `Merge pull request` button. In case of conflicts, please resolve them manually with usign the following commands: ``` git fetch upstream gh pr checkout <this-pr-number> git merge upstream/1.14 -m "Resolve conflicts between 1.13 and 1.14" ``` If you use other name for the upstream remote, please replace `upstream` with the name of your remote pointing to the `Sylius/Sylius` repository. Once the conflicts are resolved, please run `git merge --continue` and push the changes to this PR.
This PR was merged into the 1.13 branch. Discussion ---------- | Q | A |-----------------|----- | Branch? | 1.13 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | n/a | License | MIT <!-- - Bug fixes must be submitted against the 1.13 branch - Features and deprecations must be submitted against the 1.14 branch - Features, removing deprecations and BC breaks must be submitted against the 2.0 branch - Make sure that the correct base branch is set To be sure you are not breaking any Backward Compatibilities, check the documentation: https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html --> Fix failing phpunit tests after year change 😄 Also fixed problem with refreshing cart items (when trying to add to cart product that is out of stock) - https://github.com/Sylius/Sylius/actions/runs/12578839374/job/35058194576#step:14:293 Caused by doctrine/orm fix - https://github.com/doctrine/orm/pull/10065/files Commits ------- [Bug] Fix statistics tests in new year Fix Doctrine ORM bug Minor changes after CR
This PR has been generated automatically. For more details see [upmerge_pr.yaml](/Sylius/Sylius/blob/1.13/.github/workflows/upmerge_pr.yaml). **Remember!** The upmerge should always be merged with using `Merge pull request` button. In case of conflicts, please resolve them manually with usign the following commands: ``` git fetch upstream gh pr checkout <this-pr-number> git merge upstream/1.14 -m "Resolve conflicts between 1.13 and 1.14" ``` If you use other name for the upstream remote, please replace `upstream` with the name of your remote pointing to the `Sylius/Sylius` repository. Once the conflicts are resolved, please run `git merge --continue` and push the changes to this PR.
This PR has been generated automatically. For more details see [refactor.yaml](/Sylius/Sylius/blob/1.12/.github/workflows/refactor.yaml).
WalkthroughThis pull request introduces a new service for resetting cart changes in the Sylius OrderBundle. The changes include creating a new Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/Sylius/Bundle/OrderBundle/Resetter/CartChangesResetter.php (1)
34-43: Consider concurrency safety and potential performance impact.
Refreshing items and the cart could be costly if performed repeatedly or for large carts at scale. If concurrency is a concern, ensure that other operations on the same cart are managed in a consistent manner. Overall, this logic is acceptable but keep an eye on performance implications in heavily concurrent environments.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
src/Sylius/Bundle/AdminBundle/Resources/views/Grid/deleteCatalogPromotion.html.twig(1 hunks)src/Sylius/Bundle/OrderBundle/Controller/OrderController.php(3 hunks)src/Sylius/Bundle/OrderBundle/Resetter/CartChangesResetter.php(1 hunks)src/Sylius/Bundle/OrderBundle/Resetter/CartChangesResetterInterface.php(1 hunks)src/Sylius/Bundle/OrderBundle/Resources/config/services.xml(1 hunks)src/Sylius/Bundle/OrderBundle/spec/Resetter/CartChangesResetterSpec.php(1 hunks)src/Sylius/Bundle/UiBundle/Resources/views/Grid/Action/default.html.twig(1 hunks)tests/Api/Responses/admin/statistics/get_day_statistics_response.json(1 hunks)tests/Api/Responses/admin/statistics/get_month_statistics_response.json(1 hunks)tests/Api/Responses/admin/statistics/get_year_statistics_response.json(1 hunks)
🔇 Additional comments (12)
src/Sylius/Bundle/UiBundle/Resources/views/Grid/Action/default.html.twig (1)
3-3: Clear fallback logic for thepathvariable.By checking if
options.link.url|default('') is not empty, you ensure that a non-emptyoptions.link.urltakes precedence and that the fallback route is used otherwise. This prevents empty strings from overriding the fallback path. Nicely done!src/Sylius/Bundle/AdminBundle/Resources/views/Grid/deleteCatalogPromotion.html.twig (1)
1-1: Consistent path construction approach.This approach correctly prioritizes
options.link.urlwhen it’s non-empty, falling back to a route-based path otherwise. It aligns well with similar logic in the other templates, keeping path resolution consistent.src/Sylius/Bundle/OrderBundle/Resetter/CartChangesResetterInterface.php (1)
18-21: Straightforward interface definition.
This interface neatly declares the expected contract for resetting cart changes. It is concise, properly typed, and follows Sylius coding standards.src/Sylius/Bundle/OrderBundle/Resetter/CartChangesResetter.php (1)
22-24: Constructor with readonly property.
Using a constructor with a readonly property is a clear and succinct approach to ensure immutability of theEntityManagerInterface. This is good practice.src/Sylius/Bundle/OrderBundle/spec/Resetter/CartChangesResetterSpec.php (1)
49-73: Good test coverage for new and managed item units.
These specifications thoroughly cover the key scenarios: unmanaged carts and carts containing both new and existing item units. Consider adding more cases (e.g., no items in the cart) if needed to strengthen completeness.src/Sylius/Bundle/OrderBundle/Controller/OrderController.php (3)
17-17: New import forCartChangesResetterInterface.
The imported interface ensures that the controller depends on the cart resetter abstraction rather than a concrete implementation. This is a solid design choice.
126-126: Cart reset after invalid submission.
Calling$this->getCartResetter()->resetChanges($resource);is correct to clear changes on an invalid cart. This helps maintain consistency when the form fails validation.
223-226: Getter method returning the resetter service.
This method is straightforward and aligns with the existing service-access pattern in this controller.src/Sylius/Bundle/OrderBundle/Resources/config/services.xml (1)
90-93: LGTM! Service configuration follows Symfony best practices.The service definition and interface alias are properly configured. The service follows the bundle's naming conventions and dependency injection practices.
Let's verify the existence of the service class and interface:
✅ Verification successful
Service class and interface are properly implemented
The verification confirms that:
- The
CartChangesResetterclass exists at the correct location- The
CartChangesResetterInterfaceinterface exists at the correct location- The class properly implements the interface
- Both files are in the expected
Resetterdirectory🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of CartChangesResetter class and interface # Check for the class file fd --type f "CartChangesResetter.php" src/Sylius/Bundle/OrderBundle # Check for the interface file fd --type f "CartChangesResetterInterface.php" src/Sylius/Bundle/OrderBundle # Verify class implements interface rg "class CartChangesResetter implements CartChangesResetterInterface" src/Sylius/Bundle/OrderBundleLength of output: 517
tests/Api/Responses/admin/statistics/get_year_statistics_response.json (1)
19-19: Verify data consistency across statistics endpointsThe change to
newCustomersCountis consistent with other statistics files, but we should verify that this reflects the expected behavior in the corresponding test scenarios.Run the following script to check for consistency in test scenarios:
✅ Verification successful
Change to
newCustomersCountis consistent with test scenariosBased on the test files analysis, the change from 1 to 0 in
newCustomersCountis correct and consistent with the test scenarios. TheStatisticsTest.phpshows that the test data is set up using fixture files andfulfillOrdermethod calls, where orders are created with specific dates but no new customers are explicitly created during the test period, justifying thenewCustomersCount: 0in the response files.Key evidence:
- The test
it_gets_fulfilled_orders_in_specific_year_statisticsinStatisticsTest.phpfocuses on order fulfillment and sales statistics- The test uses fixtures and
fulfillOrdermethod to set up test data, but doesn't create new customers- All statistics response files (
get_day_statistics_response.json,get_month_statistics_response.json, andget_year_statistics_response.json) consistently shownewCustomersCount: 0🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for consistency in customer count assertions across test files # Look for related test assertions that might need updating # Search for test files asserting customer counts rg -l "newCustomersCount" "tests/Api" --type php # Search for customer creation in test setup rg -l "createCustomer|addCustomer" "tests/Api" --type phpLength of output: 104
Script:
#!/bin/bash # Let's try a broader search to understand the test structure and related files # Find all JSON files in tests directory that might contain statistics fd -e json -p "statistics.*response" tests/ # Check content of these files for newCustomersCount for f in $(fd -e json -p "statistics.*response" tests/); do echo "=== $f ===" cat "$f" | grep -A 2 -B 2 "newCustomersCount" done # Look for test files that might be setting up this scenario fd -e php tests/ --exec grep -l "statistics"Length of output: 2988
Script:
#!/bin/bash # Let's check the test files that might be setting up these scenarios # Search for test files in the tests directory fd -e php . tests/ --exec grep -l "statistics" # Also check for any test setup related to these statistics fd -e php . tests/ --exec grep -A 5 -B 5 "function.*test.*statistics"Length of output: 187
Script:
#!/bin/bash # Let's examine the test files we found # Check the content of StatisticsTest.php echo "=== StatisticsTest.php ===" cat tests/Api/Admin/StatisticsTest.php # Check the content of CustomersTest.php echo "=== CustomersTest.php ===" cat tests/Api/Admin/CustomersTest.phpLength of output: 26532
tests/Api/Responses/admin/statistics/get_month_statistics_response.json (1)
151-151: Consistent change with other statistics endpointsThe update to
newCustomersCountaligns with the changes in other statistics responses while preserving the existing sales patterns.tests/Api/Responses/admin/statistics/get_day_statistics_response.json (1)
4391-4391: Verify impact on statistics calculationThe consistent update of
newCustomersCountacross all statistics endpoints suggests a change in how new customers are counted or tested. This might be related to changes in the underlying statistics calculation logic.Run the following script to investigate related changes:
✅ Verification successful
Let me gather more specific information about the customer counting logic.
Let me check one more aspect to understand how the new customers count is calculated.
Let me check one final aspect to see the actual implementation of new customers counting.
Let me try one more search with a simpler pattern.
Test data update reflects actual customer counting logic
The change in
newCustomersCountfrom 1 to 0 in the test response file is consistent with the actual implementation. TheBusinessActivitySummaryProvidercalculates new customers usingcustomerRepository->countCustomersInPeriod()for the given date range, and this test data represents a scenario where no new customers were registered during that period.Key findings:
- The value is determined by actual customer repository counting, not hardcoded
- The test data aligns with a valid business scenario where no new customers were added
- The implementation is consistent across the statistics system
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Look for changes in statistics calculation logic # Search for statistics-related classes and services rg -l "Statistics|CustomerStatistics" "src/" # Search for customer counting logic ast-grep --pattern 'class $_ { $$$ count($$$) { $$$ } $$$ }'Length of output: 5893
Script:
#!/bin/bash # Search for new customer counting logic in statistics providers rg -A 10 "newCustomers" src/ # Look for test files related to customer statistics fd -e php -e feature "customer.*stat" tests/Length of output: 4603
Script:
#!/bin/bash # Look for the business activity summary provider implementation rg -A 15 "class BusinessActivitySummaryProvider" src/Length of output: 3962
Script:
#!/bin/bash # Get the full implementation of BusinessActivitySummaryProvider rg -A 30 "provide\(\\\DatePeriod \$datePeriod" src/Length of output: 51
Script:
#!/bin/bash # Get the implementation details of BusinessActivitySummaryProvider rg -A 30 "public function provide" "src/Sylius/Component/Core/Statistics/Provider/BusinessActivitySummaryProvider.php"Length of output: 783
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
tests/Api/Responses/admin/statistics/get_day_statistics_response.json (1)
4391-4391: Document the change in customer count calculationThis completes the pattern of changing
newCustomersCountfrom 1 to 0 across all statistics response files (day, month, and year). Consider adding a note in the migration guide or changelog to document this behavioral change if it affects the API response in production.src/Sylius/Bundle/OrderBundle/Resetter/CartChangesResetter.php (1)
40-42: Minimize refresh calls for performanceCalling
$this->manager->refresh($item);inside a loop and then refreshing$cartagain may lead to extra overhead for carts containing many items. Consider refreshing only once on the cart itself if that suffices to keep items in sync.src/Sylius/Bundle/OrderBundle/Controller/OrderController.php (1)
223-226: Recommend injecting CartChangesResetterInterface directlyAccessing the service via
$this->get('sylius.resetter.cart_changes')relies on the container and is more common in legacy code. In newer Symfony applications, consider injecting this service into the controller’s constructor or using autowiring to make testing and maintenance easier.src/Sylius/Bundle/OrderBundle/Resources/config/services.xml (1)
90-93: Consider making the service private if not used directly.The service declarations look good and follow Symfony's best practices. However, if the cart changes resetter is only used internally through dependency injection, consider making it private for better encapsulation.
- <service id="sylius.resetter.cart_changes" class="Sylius\Bundle\OrderBundle\Resetter\CartChangesResetter"> + <service id="sylius.resetter.cart_changes" class="Sylius\Bundle\OrderBundle\Resetter\CartChangesResetter" public="false"> <argument type="service" id="sylius.manager.order" /> </service>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
src/Sylius/Bundle/AdminBundle/Resources/views/Grid/deleteCatalogPromotion.html.twig(1 hunks)src/Sylius/Bundle/OrderBundle/Controller/OrderController.php(3 hunks)src/Sylius/Bundle/OrderBundle/Resetter/CartChangesResetter.php(1 hunks)src/Sylius/Bundle/OrderBundle/Resetter/CartChangesResetterInterface.php(1 hunks)src/Sylius/Bundle/OrderBundle/Resources/config/services.xml(1 hunks)src/Sylius/Bundle/OrderBundle/spec/Resetter/CartChangesResetterSpec.php(1 hunks)src/Sylius/Bundle/UiBundle/Resources/views/Grid/Action/default.html.twig(1 hunks)tests/Api/Responses/admin/statistics/get_day_statistics_response.json(1 hunks)tests/Api/Responses/admin/statistics/get_month_statistics_response.json(1 hunks)tests/Api/Responses/admin/statistics/get_year_statistics_response.json(1 hunks)
🔇 Additional comments (11)
src/Sylius/Bundle/UiBundle/Resources/views/Grid/Action/default.html.twig (1)
3-3: Fallback Logic for Path Looks GoodThe new ternary condition ensures that
options.link.urlis used when provided and falls back gracefully topath(options.link.route, options.link.parameters|default({}))otherwise. This enhanced logic is clear and improves template flexibility for link generation.src/Sylius/Bundle/AdminBundle/Resources/views/Grid/deleteCatalogPromotion.html.twig (1)
1-1: Similar Fallback ImplementationJust like in the other template, the ternary check for
options.link.urlpromotes consistency and clarity. By ensuring that a non-emptyoptions.link.urltakes precedence, the template remains more adaptable to different link generation strategies.tests/Api/Responses/admin/statistics/get_year_statistics_response.json (1)
19-19: Verify the intentional change in customer countThe
newCustomersCounthas been changed from 1 to 0. This change appears in all statistics response files, suggesting a deliberate modification. Please confirm if this is an intentional change as part of the upmerge from v1.14 to v2.0.Run the following script to check for related changes in the test implementation:
✅ Verification successful
Let me gather more information about the changes in these files.
Let me check the content of other statistics response files to see if this is a consistent pattern.
Let me try a different approach to check the other statistics files and related test files.
Let me check the test implementation to understand if this is a deliberate change.
Let me check the feature files and context files to understand the expected behavior.
Based on the analysis of the feature files and test implementations, I can now provide a final response.
The change in customer count is consistent with test expectations
The change from 1 to 0 in
newCustomersCountin the statistics response fixtures is correct and matches the test scenarios. The feature files show that customer counts are explicitly verified in scenarios and the statistics are calculated based on fulfilled orders, not just placed orders. The test fixtures serve as expected responses for API tests, and the zero count appears to be the default state for new statistics responses.Key observations:
- The feature files contain explicit scenarios verifying customer counts
- The DashboardContext implements verification of
newCustomersCountthrough the API- The statistics response files are used as fixtures for API testing
- The zero count represents the initial/default state for test cases
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for related changes in test implementations that might explain the customer count change # Search for test files that might set up this fixture data rg -l "newCustomersCount" --type php # Search for any changes in how customer count is calculated ast-grep --pattern 'function $_(CustomerCount|getNewCustomers)'Length of output: 425
Script:
#!/bin/bash # Check the content of the files that reference newCustomersCount cat src/Sylius/Bundle/ApiBundle/OpenApi/Documentation/StatisticsDocumentationModifier.php cat src/Sylius/Behat/Context/Api/Admin/DashboardContext.php cat src/Sylius/Component/Core/Statistics/ValueObject/BusinessActivitySummary.php # Check for other test fixtures with similar statistics fd -e json statistics_responseLength of output: 12058
Script:
#!/bin/bash # Check the content of all statistics response files cat tests/Api/Responses/admin/statistics/get_day_statistics_response.json cat tests/Api/Responses/admin/statistics/get_month_statistics_response.json cat tests/Api/Responses/admin/statistics/get_year_statistics_response.json # Check git history for these files to see when and why the change was made git log -p tests/Api/Responses/admin/statistics/get_year_statistics_response.jsonLength of output: 65826
Script:
#!/bin/bash # Check the content of the business activity summary in all statistics response files rg -l "businessActivitySummary" tests/Api/Responses/admin/statistics/ cat tests/Api/Responses/admin/statistics/get_month_statistics_response.json cat tests/Api/Responses/admin/statistics/get_year_statistics_response.json # Check for any test files that might be setting up this data rg -l "newCustomersCount.*[01]" tests/Length of output: 4090
Script:
#!/bin/bash # Check for test files that set up or verify the statistics data rg -A 5 "newCustomersCount" tests/Behat/Context/Api/Admin/DashboardContext.php # Check for any feature files that might describe the expected behavior fd -e feature . tests/ | xargs rg -l "new customers"Length of output: 463
Script:
#!/bin/bash # Check the feature files for expected behavior cat features/admin/statistics.feature cat features/admin/statistics_per_channel.feature # Check the context files for implementation cat src/Sylius/Behat/Context/Api/Admin/DashboardContext.php cat src/Sylius/Behat/Context/Setup/OrderContext.phpLength of output: 55825
tests/Api/Responses/admin/statistics/get_month_statistics_response.json (1)
151-151: Consistent change in customer countThe change from 1 to 0 in
newCustomersCountis consistent with the modification inget_year_statistics_response.json.src/Sylius/Bundle/OrderBundle/Resetter/CartChangesResetterInterface.php (1)
1-21: Interface looks goodNo issues found. The interface definition is concise and follows standard practices for extending functionality without introducing implementation details.
src/Sylius/Bundle/OrderBundle/Resetter/CartChangesResetter.php (2)
28-30: Consider handling unmanaged carts more explicitlyCurrently, the method returns immediately if
$cartis not contained in the EntityManager. You might want to confirm that ignoring carts outside persistence context is the intended behavior (e.g., by logging a debug message or throwing an exception). Otherwise, debugging issues with untracked carts might be harder.
34-39: Good approach to remove new unitsRemoving units in the
STATE_NEWstate is a straightforward solution to revert cart changes. This implementation is clear and explicit.src/Sylius/Bundle/OrderBundle/spec/Resetter/CartChangesResetterSpec.php (1)
1-74: Spec tests are comprehensiveYour spec covers both scenarios—when the cart is not managed and when it has new item units. This thorough test coverage is excellent, ensuring stable behavior of the resetter logic.
src/Sylius/Bundle/OrderBundle/Controller/OrderController.php (2)
17-17: Interface dependency properly introducedImporting
CartChangesResetterInterfaceprovides a clear contract for cart reset logic. No issues here.
126-126: Verify the cart object type before resettingWhen
$formis invalid, calling$this->getCartResetter()->resetChanges($resource);might fail if$resourceis not an expectedOrderInterface. Ensure$resourceis indeed a cart to avoid unexpected type issues.src/Sylius/Bundle/OrderBundle/Resources/config/services.xml (1)
90-93: Verify integration with OrderController.The service looks properly configured. Let's verify its integration with the OrderController mentioned in the summary.
✅ Verification successful
Integration with OrderController is properly implemented
The verification confirms that the CartChangesResetter service is correctly integrated with the OrderController:
- The controller properly retrieves the service through
getCartResetter()method which returnsCartChangesResetterInterface- The service is used in the
saveAction()method to reset cart changes when form validation fails:if ($form->isSubmitted() && !$form->isValid()) { $this->getCartResetter()->resetChanges($resource); $this->addFlash('error', 'sylius.cart.not_recalculated'); }
- The service is correctly retrieved using the service ID
sylius.resetter.cart_changesthat matches the configuration inservices.xmlThe integration is complete and working as expected.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of CartChangesResetter with OrderController # Check if OrderController uses the new service ast-grep --pattern 'class OrderController { $$$ private function getCartResetter(): CartChangesResetterInterface { $$$ } $$$ }' # Verify service usage in saveAction ast-grep --pattern 'public function saveAction(Request $request, $resource) { $$$ getCartResetter()->resetChanges($resource) $$$ }'Length of output: 489
Script:
#!/bin/bash # Let's try a different approach using ripgrep to find the OrderController and its usage of CartChangesResetter # Find OrderController files echo "=== Finding OrderController files ===" rg -l "class OrderController" # Search for CartChangesResetter usage echo -e "\n=== Searching for CartChangesResetter usage ===" rg -l "CartChangesResetter" # Search for getCartResetter method echo -e "\n=== Searching for getCartResetter method ===" rg "getCartResetter" # Search for resetChanges method calls echo -e "\n=== Searching for resetChanges method calls ===" rg "resetChanges\("Length of output: 1817
Script:
#!/bin/bash # Let's check the implementation details of OrderController to understand the integration better echo "=== OrderController Implementation ===" cat src/Sylius/Bundle/OrderBundle/Controller/OrderController.phpLength of output: 9490
… to a parameter (#17611) | Q | A |-----------------|----- | Branch? | 1.14 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | - | License | MIT
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
UPGRADE-1.14.md (1)
Line range hint
7-1000: Comprehensive documentation of service changes.The extensive list of service changes is well-documented with clear mappings between old and new service IDs. This will help developers during the upgrade process.
Consider using a migration script to help users identify and update their service references automatically.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
UPGRADE-1.14.md(1 hunks)src/Sylius/Bundle/CoreBundle/Resources/config/services/order_processing.xml(1 hunks)
🔇 Additional comments (4)
UPGRADE-1.14.md (1)
1-5: LGTM! Clear documentation of the parameter extraction.The change improves configurability by extracting hardcoded adjustment types into a configurable parameter. This is a good practice for maintainability and flexibility.
src/Sylius/Bundle/CoreBundle/Resources/config/services/order_processing.xml (3)
28-35: Well-structured parameter definition!The new parameter definition follows best practices by:
- Using constants instead of string literals
- Centralizing adjustment types in a single, reusable collection
- Including all necessary adjustment types (promotions, shipping, tax)
41-41: Clean service argument refactoring!The modification properly references the new parameter collection, improving maintainability by removing hardcoded values while preserving the service's functionality.
28-35: Verify completeness of adjustment types.Let's ensure no adjustment types are missing from the collection.
✅ Verification successful
Collection includes all adjustment types defined in the interface.
The adjustment clearing types collection in
order_processing.xmlperfectly matches all the constants defined inSylius\Component\Core\Model\AdjustmentInterface. No adjustment types are missing.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any other adjustment type constants in AdjustmentInterface # that might have been missed in the collection ast-grep --pattern 'interface AdjustmentInterface { $$$ const $ADJUSTMENT_TYPE = $_; $$$ }' # Also search for any direct string usage of adjustment types rg -i "adjustment.*type.*=.*['\"]" --type phpLength of output: 1664
Script:
#!/bin/bash # Find the AdjustmentInterface file fd -e php AdjustmentInterface # Once found, let's look at its contents fd -e php AdjustmentInterface -x cat {}Length of output: 2917
| 1. Extracted a new `sylius.order_processing.adjustment_clearing_types` parameter responsible for the collection of adjustment types to be cleared during order processing. | ||
| Previously the collection of types was hardcoded as an argument of the `sylius.order_processing.order_adjustments_clearer` service. |
There was a problem hiding this comment.
💡 Codebase verification
Breaking change requires additional documentation and default value
The extraction of hardcoded adjustment types into a parameter sylius.order_processing.adjustment_clearing_types is a breaking change that needs attention:
- The parameter is not defined with default values in any configuration files
- The upgrade guide lacks migration instructions for existing implementations
- No information about the previously hardcoded values that should be used in the parameter
🔗 Analysis chain
Verify the impact of this change on existing configurations.
Since this is a breaking change in configuration, ensure all existing implementations using the sylius.order_processing.order_adjustments_clearer service are updated to use the new parameter.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Find all usages of the order_adjustments_clearer service to identify affected configurations
# Search for direct service usage
rg -A 5 "sylius.order_processing.order_adjustments_clearer"
# Search for adjustment type constants usage
ast-grep --pattern 'AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT'
Length of output: 6713
Script:
#!/bin/bash
# Search for parameter definition and related configuration
rg -l "sylius.order_processing.adjustment_clearing_types"
# Check parameters.xml or similar files
fd parameters.xml --exec cat {}
# Look for upgrade instructions
rg -A 5 "adjustment_clearing_types" UPGRADE-1.14.md
Length of output: 599
Script:
#!/bin/bash
# Search for parameter configuration in core bundle
fd -e php -e yaml -e xml . src/Sylius/Bundle/CoreBundle --exec rg -l "adjustment_clearing_types" {}
# Search for DependencyExtension and Configuration classes
fd "DependencyExtension|Configuration" . src/Sylius/Bundle/CoreBundle --exec cat {}
Length of output: 69164
Script:
#!/bin/bash
# Search for parameter definition in CoreBundle
fd -e yml -e yaml -e xml . src/Sylius/Bundle/CoreBundle/Resources/config --exec cat {}
# Search for CoreBundle extension class
fd -e php CoreExtension src/Sylius/Bundle/CoreBundle --exec cat {}
Length of output: 74078
This PR has been generated automatically.
For more details see upmerge_pr.yaml.
Remember! The upmerge should always be merged with using
Merge pull requestbutton.In case of conflicts, please resolve them manually with usign the following commands:
If you use other name for the upstream remote, please replace
upstreamwith the name of your remote pointing to theSylius/Syliusrepository.Once the conflicts are resolved, please run
git merge --continueand push the changes to this PR.Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Tests