Skip to content

[UPMERGE] 1.14 -> 2.0#17604

Merged
GSadee merged 12 commits into2.0from
upmerge/1.14_2.0
Jan 10, 2025
Merged

[UPMERGE] 1.14 -> 2.0#17604
GSadee merged 12 commits into2.0from
upmerge/1.14_2.0

Conversation

@SyliusBot
Copy link
Copy Markdown
Contributor

@SyliusBot SyliusBot commented Jan 4, 2025

This PR has been generated automatically.
For more details see 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/2.0 -m "Resolve conflicts between 1.14 and 2.0"

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.

Summary by CodeRabbit

  • New Features

    • Introduced a new service for resetting cart changes.
    • Added a new interface for managing cart changes.
    • Added a new parameter for configurable adjustment clearing types in order processing.
  • Bug Fixes

    • Improved handling of URL path generation in Twig templates.
    • Updated statistics response to reflect accurate new customer counts.
  • Refactor

    • Restructured cart change management in the order processing workflow.
    • Moved cart changes reset logic to a dedicated service.
  • Tests

    • Added specification tests for the new cart changes resetter.

JeanDavidDaviet and others added 10 commits December 11, 2024 11:45
#17566)

| Q               | A
|-----------------|-----
| Branch?         | 1.13
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | fixes #17565 
| License         | MIT
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).
@SyliusBot SyliusBot requested review from a team as code owners January 4, 2025 02:23
@probot-autolabeler probot-autolabeler bot added the Admin AdminBundle related issues and PRs. label Jan 4, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 4, 2025

Walkthrough

This pull request introduces a new service for resetting cart changes in the Sylius OrderBundle. The changes include creating a new CartChangesResetterInterface and its implementation CartChangesResetter, which provides a mechanism to remove new units from cart items. The modifications also update the service configuration and add corresponding specification tests. Additionally, there are minor template adjustments in grid action rendering and updates to test response JSON files reflecting changes in customer count statistics.

Changes

File Change Summary
src/Sylius/Bundle/AdminBundle/Resources/views/Grid/deleteCatalogPromotion.html.twig Enhanced path variable assignment with explicit empty string check
src/Sylius/Bundle/UiBundle/Resources/views/Grid/Action/default.html.twig Similar path variable logic modification
src/Sylius/Bundle/OrderBundle/Controller/OrderController.php Replaced local resetChangesOnCart method with service-based cart changes resetting
src/Sylius/Bundle/OrderBundle/Resetter/CartChangesResetterInterface.php New interface defining cart changes reset method
src/Sylius/Bundle/OrderBundle/Resetter/CartChangesResetter.php New implementation of cart changes reset logic
src/Sylius/Bundle/OrderBundle/Resources/config/services.xml Added new service definitions for cart changes resetter
tests/Api/Responses/admin/statistics/* Updated newCustomersCount from 1 to 0 in various statistic response JSONs
UPGRADE-1.14.md Introduced new parameter for configurable adjustment clearing types in order processing
src/Sylius/Bundle/CoreBundle/Resources/config/services/order_processing.xml Added new parameter for adjustment clearing types in order processing services

Possibly related PRs

Suggested reviewers

  • mpysiak

Poem

🐰 A Rabbit's Ode to Cart Resets 🛒
In Sylius' realm of shopping delight,
Cart changes dance, then take flight
With services clean and logic so neat,
Our code now dances to a smoother beat!
Hop, hop, hooray for refactored grace! 🎉


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between c2a89d1 and 4cc2b12.

📒 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 the path variable.

By checking if options.link.url|default('') is not empty, you ensure that a non-empty options.link.url takes 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.url when 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 the EntityManagerInterface. 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 for CartChangesResetterInterface.
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 CartChangesResetter class exists at the correct location
  • The CartChangesResetterInterface interface exists at the correct location
  • The class properly implements the interface
  • Both files are in the expected Resetter directory
🏁 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/OrderBundle

Length of output: 517

tests/Api/Responses/admin/statistics/get_year_statistics_response.json (1)

19-19: Verify data consistency across statistics endpoints

The change to newCustomersCount is 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 newCustomersCount is consistent with test scenarios

Based on the test files analysis, the change from 1 to 0 in newCustomersCount is correct and consistent with the test scenarios. The StatisticsTest.php shows that the test data is set up using fixture files and fulfillOrder method calls, where orders are created with specific dates but no new customers are explicitly created during the test period, justifying the newCustomersCount: 0 in the response files.

Key evidence:

  • The test it_gets_fulfilled_orders_in_specific_year_statistics in StatisticsTest.php focuses on order fulfillment and sales statistics
  • The test uses fixtures and fulfillOrder method 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, and get_year_statistics_response.json) consistently show newCustomersCount: 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 php

Length 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.php

Length of output: 26532

tests/Api/Responses/admin/statistics/get_month_statistics_response.json (1)

151-151: Consistent change with other statistics endpoints

The update to newCustomersCount aligns 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 calculation

The consistent update of newCustomersCount across 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 newCustomersCount from 1 to 0 in the test response file is consistent with the actual implementation. The BusinessActivitySummaryProvider calculates new customers using customerRepository->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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 calculation

This completes the pattern of changing newCustomersCount from 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 performance

Calling $this->manager->refresh($item); inside a loop and then refreshing $cart again 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 directly

Accessing 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

📥 Commits

Reviewing files that changed from the base of the PR and between c2a89d1 and 4cc2b12.

📒 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 Good

The new ternary condition ensures that options.link.url is used when provided and falls back gracefully to path(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 Implementation

Just like in the other template, the ternary check for options.link.url promotes consistency and clarity. By ensuring that a non-empty options.link.url takes 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 count

The newCustomersCount has 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 newCustomersCount in 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 newCustomersCount through 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_response

Length 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.json

Length 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.php

Length of output: 55825

tests/Api/Responses/admin/statistics/get_month_statistics_response.json (1)

151-151: Consistent change in customer count

The change from 1 to 0 in newCustomersCount is consistent with the modification in get_year_statistics_response.json.

src/Sylius/Bundle/OrderBundle/Resetter/CartChangesResetterInterface.php (1)

1-21: Interface looks good

No 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 explicitly

Currently, the method returns immediately if $cart is 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 units

Removing units in the STATE_NEW state 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 comprehensive

Your 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 introduced

Importing CartChangesResetterInterface provides a clear contract for cart reset logic. No issues here.


126-126: Verify the cart object type before resetting

When $form is invalid, calling $this->getCartResetter()->resetChanges($resource); might fail if $resource is not an expected OrderInterface. Ensure $resource is 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:

  1. The controller properly retrieves the service through getCartResetter() method which returns CartChangesResetterInterface
  2. 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');
}
  1. The service is correctly retrieved using the service ID sylius.resetter.cart_changes that matches the configuration in services.xml

The 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.php

Length of output: 9490

NoResponseMate and others added 2 commits January 9, 2025 10:23
… to a parameter (#17611)

| Q               | A
|-----------------|-----
| Branch?         | 1.14
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | -
| License         | MIT
@probot-autolabeler probot-autolabeler bot added the Maintenance CI configurations, READMEs, releases, etc. label Jan 10, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4cc2b12 and 22e39f7.

📒 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.xml perfectly matches all the constants defined in Sylius\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 php

Length 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

Comment on lines +3 to +4
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.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Admin AdminBundle related issues and PRs. Maintenance CI configurations, READMEs, releases, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants