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

Inconsistent cms block validation and save methods #4831

Open
vovayatsyuk opened this issue Jun 2, 2016 · 16 comments
Open

Inconsistent cms block validation and save methods #4831

vovayatsyuk opened this issue Jun 2, 2016 · 16 comments

Comments

@vovayatsyuk
Copy link
Contributor

@vovayatsyuk vovayatsyuk commented Jun 2, 2016

Additional information

The issue was reopened on 16 July 2019.
The reopening reason is that current behavior(after fixes) brings new issues. See comment for details

  1. Currently, I have to re-save an existing block (select every store view except one manually) and only after that, I can finally create a block for a specific store view.
  2. Previously, I could add a new block and it just works. Magento correctly used the fallback mechanism to show the correct block at every store view.

Additionally, when using a new approach, if I'll create a new store view I have to open cms block again and select newly created store view in store views combo box. Previously all work flawlessly because I always had a default block saved with "All store views" selected.

Preconditions

Magento develop branch

Steps to reproduce

  1. Install Magento from develop branch.
  2. Make sure that you have only one store view and SingleStoreMode option in disabled
  3. Create cms block example for All Store views
  4. Create another cms block example for first store view only

Expected result

  1. Block should be saved for selected store view

Actual result

  1. An exception will be thrown:

    A block identifier with the same properties already exists in the selected store.
    

Propose

Validator should validate actual block data, so we can remove the following check completely:

if ($this->_storeManager->hasSingleStore()) {
    $stores = [Store::DEFAULT_STORE_ID];
}

https://github.com/magento/magento2/blob/develop/app/code/Magento/Cms/Model/ResourceModel/Block.php#L186-L188

OR

this logic should be moved to _beforeSave and slightly modified, to check SingleStoreMode option:

if ($this->_storeManager->getSingleStoreMode()) {
    $object->setData('stores', [Store::DEFAULT_STORE_ID]);
}
@vkorotun vkorotun removed the PS label Aug 4, 2016
@IlnitskiyArtem

This comment has been minimized.

Copy link

@IlnitskiyArtem IlnitskiyArtem commented Jun 23, 2017

@vovayatsyuk, Thanks for the feedback.
I reproduced it on last Magento 2 develop branch. Also i tried to create CMS Blocks with same identifiers at first for the Default Store View, and just then for All. In such way it worked.
The logic is that when you create it for All Sore Views at first with Single Store mode disabled, CMS Block identifier Is for all stores and cannot be duplicated. In other way, when you create it for a particular Store View, it checks just certain area where it is already created.
That functional with disable Single Store is not a bug.

@vovayatsyuk

This comment has been minimized.

Copy link
Contributor Author

@vovayatsyuk vovayatsyuk commented Jun 23, 2017

Thanks, I know why it shows an error and I wrote a proposed solution that will fix this behavior.

If you'll dig into this a little more, you'll see that validation and save methods are inconsistent:

Save method uses data from the request, while validation does not. Validation put a [Store::DEFAULT_STORE_ID] into $stores variable but the actual stores are left in the object and will be saved as well if validation will return true.

And that is a bug, I think. It's not a valid behavior when validation checks data that will not be saved actually.

@magento-engcom-team

This comment has been minimized.

Copy link
Contributor

@magento-engcom-team magento-engcom-team commented Sep 19, 2017

@vovayatsyuk thank you for your bug report.
We've created internal ticket MAGETWO-75216 to track progress on the issue.

@thiagolima-bm

This comment has been minimized.

Copy link
Member

@thiagolima-bm thiagolima-bm commented Nov 4, 2017

I am working on it at #mm17es

@thiagolima-bm

This comment has been minimized.

Copy link
Member

@thiagolima-bm thiagolima-bm commented Nov 4, 2017

this was fixed already #11805

@vrann vrann added the mm17es label Nov 4, 2017
@okorshenko

This comment has been minimized.

Copy link
Contributor

@okorshenko okorshenko commented Dec 14, 2017

Hi @vovayatsyuk
The issue has been fixed in #11805
@thiagolima-bm thank you for your contribution! 👍

@magento-engcom-team

This comment has been minimized.

Copy link
Contributor

@magento-engcom-team magento-engcom-team commented Jun 19, 2019

Confirmed by @engcom-Charlie
Thank you for verifying the issue. Based on the provided information internal tickets MC-17603, MC-17604 were created

Issue Available: @engcom-Charlie, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@sdzhepa

This comment has been minimized.

Copy link
Contributor

@sdzhepa sdzhepa commented Jul 11, 2019

Hello @vovayatsyuk and @orlangur

All internal Jira tickets(MC-17604, MC-17603) related to this issue were closed by Magento team with resolution Not a Bug.
Because of the quote:

it's expected behavior, that we can't save block with the same identifier for specific store view if it's already saved for all store views.

It was fixed intentionally.
Additional information:

  • GitHub issue #8236 with original report
  • PR: #11802 to fix it

Also additional bug related to this issue was fixed by internal team in the scop of MAGETWO-91559

@sdzhepa sdzhepa closed this Jul 11, 2019
@m2-backlog m2-backlog bot moved this from Ready for Dev to Done (last 30 days) in Community Backlog Jul 11, 2019
@sdzhepa sdzhepa added the non-issue label Jul 11, 2019
@vovayatsyuk

This comment has been minimized.

Copy link
Contributor Author

@vovayatsyuk vovayatsyuk commented Jul 12, 2019

I strongly disagree with this quote:

it's expected behavior, that we can't save block with the same identifier for specific store view if it's already saved for all store views.

Let's work on it together to allow to do that and fix all possible issues (if any).

Let me explain:

  1. Currently, I have to re-save an existing block (select every store view except one manually) and only after that, I can finally create a block for a specific store view.
  2. Previously, I could add a new block and it just works. Magento correctly used the fallback mechanism to show the correct block at every store view.

Additionally, when using a new approach, if I'll create a new store view I have to open cms block again and select newly created store view in store views combo box. Previously all work flawlessly because I always had a default block saved with "All store views" selected.

p.s. The issue you are referring to (#8236) is about saving block with the same store_id while we are talking about different store_ids.

@sdzhepa

This comment has been minimized.

Copy link
Contributor

@sdzhepa sdzhepa commented Jul 16, 2019

Hello @vovayatsyuk

Thank you for your feedback and collaboration!

I am reopening this issue.
It seems important part/cases were missed and we should consider it again

@sdzhepa sdzhepa reopened this Jul 16, 2019
@m2-backlog m2-backlog bot moved this from Done (last 30 days) to Ready for QA in Community Backlog Jul 16, 2019
@sdzhepa sdzhepa removed the non-issue label Jul 16, 2019
@engcom-Bravo engcom-Bravo self-assigned this Jul 17, 2019
@m2-assistant

This comment has been minimized.

Copy link

@m2-assistant m2-assistant bot commented Jul 17, 2019

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@magento-engcom-team

This comment has been minimized.

Copy link
Contributor

@magento-engcom-team magento-engcom-team commented Jul 17, 2019

Confirmed by @engcom-Bravo
Thank you for verifying the issue. Based on the provided information internal tickets MC-18224 were created

Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@sergey-solo sergey-solo self-assigned this Jul 22, 2019
@m2-assistant

This comment has been minimized.

Copy link

@m2-assistant m2-assistant bot commented Jul 22, 2019

Hi @sergey-solo. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.


@m2-backlog m2-backlog bot moved this from Ready for Dev to Dev in Progress in Community Backlog Jul 22, 2019
@sergey-solo sergey-solo removed their assignment Jul 24, 2019
@m2-backlog m2-backlog bot moved this from Dev in Progress to Ready for Dev in Community Backlog Jul 24, 2019
@sergey-solo

This comment has been minimized.

Copy link
Contributor

@sergey-solo sergey-solo commented Jul 24, 2019

@PascalBrouwers

This comment has been minimized.

Copy link
Contributor

@PascalBrouwers PascalBrouwers commented Jul 31, 2019

@sdzhepa please revert and allow same identifier for specific store view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.