Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][Channel] The hostname resolver does not check for the channel status #13697

Closed
wants to merge 1 commit into from

Conversation

lruozzi9
Copy link
Contributor

Q A
Branch? 1.10
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? yes
Related tickets fixes #13677
License MIT

@lruozzi9 lruozzi9 requested a review from a team as a code owner February 24, 2022 14:06
@probot-autolabeler probot-autolabeler bot added the Maintenance CI configurations, READMEs, releases, etc. label Feb 24, 2022
@Roshyo
Copy link
Contributor

Roshyo commented Feb 25, 2022

Hi @lruozzi9 . Could it be possible to come up with a testing scenario on that please ?

@lruozzi9 lruozzi9 force-pushed the fix-hostname-channel-resolver branch from 8cb3051 to 3e14f90 Compare February 28, 2022 10:21
@lruozzi9
Copy link
Contributor Author

Done!

@lruozzi9 lruozzi9 force-pushed the fix-hostname-channel-resolver branch from 3e14f90 to b3da30b Compare March 2, 2022 09:09
Copy link
Member

@Zales0123 Zales0123 left a comment

Choose a reason for hiding this comment

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

Also, it should target 1.11 as we no longer support 1.10 branch 🖖 Thanks for your contribution!

/**
* @When I visit the homepage
*/
public function iVisitTheHomepage(): void
Copy link
Member

Choose a reason for hiding this comment

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

We should probably use Sylius\Behat\Context\Ui\Shop\HomepageContext::iCheckLatestProducts() method, just add @When I visit the homepage in steps definition 🖖

@ui
Scenario: Browsing shop in active channel
When I visit the homepage
Then I should be on channel "Alternative"
Copy link
Member

Choose a reason for hiding this comment

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

I should brows "Alternative" shop? "Channel" is not a concept Customer should be aware of 🚀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right!

Feature: Browsing shop on right channel
In order to shop
As a Customer
I want to be redirected to the right channel
Copy link
Member

Choose a reason for hiding this comment

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

I should not be able to browse disabled shop?

@@ -28,6 +28,6 @@ public function __construct(ChannelRepositoryInterface $channelRepository)

public function findChannel(Request $request): ?ChannelInterface
{
return $this->channelRepository->findOneByHostname($request->getHost());
return $this->channelRepository->findOneEnabledByHostname($request->getHost());
Copy link
Member

Choose a reason for hiding this comment

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

I have mixed feelings... because it's a good change, but also kind of a BC Break 💃 Even though the previous implementation was faulty, one could depend on it and we change the behaviour of the class and its findChannel method. Maybe we could inject a parameter in the constructor (sth like bool $onlyEnabledChannels = true), choose a proper repository method based on it and inform about this change in the UPGRADE file? This way it would be easy to return the previous behaviour by overriding the service definition 🖖

cc @lchrusciel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe you are right, but the current implementation hides a relevant bug. We have an eCommerce with two channels and with two different hosts. After a while, we added another channel with the same hostname as the first but disabled, because that channel should only contain some feed products. After creating the channel the first shop started to show the default Sylius theme and only the products available in the disabled channel. We have deleted the disabled channel, fixed the bug, and then recreated the channel to fix that problem.

@lruozzi9
Copy link
Contributor Author

Also, it should target 1.11 as we no longer support 1.10 branch 🖖 Thanks for your contribution!

It was when I opened the PR 🤣.

Zales0123 added a commit that referenced this pull request Jul 18, 2022
… status (lruozzi9, jakubtobiasz)

This PR was merged into the 1.11 branch.

Discussion
----------

| Q               | A                                                            |
|-----------------|--------------------------------------------------------------|
| Branch?         | 1.11 <!-- see the comment below -->          |
| Bug fix?        | yes                                                       |
| New feature?    | no                                                       |
| BC breaks?      | no                                                       |
| Deprecations?   | yes <!-- don't forget to update the UPGRADE-*.md file --> |
| Related tickets | continuation of #13697                      |
| License         | MIT                                                          |

<!--
 - Bug fixes must be submitted against the 1.10 or 1.11 branch(the lowest possible)
 - Features and deprecations must be submitted against the master 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
-->

What has been done:
- Updated behats (In my opinion now they're now a little bit more natural to read)
- I rebased the PR on top 1.11 and updated the `UPGRADE-1.11.md` and the `UPGRADE-1.10.md` files

We've had a discussion about parametrizing the `HostnameBasedRequestResolver` (what I've done btw 😂) but we decided to drop that idea and keep the original concept.

Thank you @lruozzi9 for your PR we could base on :). 


Commits
-------

28e39e2 [Channel] Do not consider disabled channel on hostname based request resolver
27406cd Adjust behat scenarios
066cf33 Update UPGRADE files
351425d Update deprecation message
55edb2d Remove redundant method
673eb91 Make filtering out scenario available in both ui and api contexts
@GSadee
Copy link
Member

GSadee commented Jul 19, 2022

Closing in favour of #14155

@GSadee GSadee closed this Jul 19, 2022
@lruozzi9 lruozzi9 deleted the fix-hostname-channel-resolver branch July 19, 2022 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance CI configurations, READMEs, releases, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants