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

Closed
vovayatsyuk opened this issue Jun 2, 2016 · 19 comments
Closed

Inconsistent cms block validation and save methods #4831

vovayatsyuk opened this issue Jun 2, 2016 · 19 comments
Labels
Component: Cms Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@vovayatsyuk
Copy link
Member

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]);
}
@IlnitskiyArtem
Copy link

@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
Copy link
Member Author

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 magento-engcom-team added bug report Component: Cms Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed and removed Progress: needs update Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Sep 11, 2017
@okorshenko okorshenko added the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Sep 14, 2017
@magento-engcom-team
Copy link
Contributor

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

@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Sep 19, 2017
@thiagolima-bm
Copy link
Member

I am working on it at #mm17es

@thiagolima-bm
Copy link
Member

this was fixed already #11805

@vrann vrann added the mm17es label Nov 4, 2017
@okorshenko
Copy link
Contributor

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

@sdzhepa sdzhepa reopened this Jul 16, 2019
@ghost ghost removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels 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
Copy link

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.

@engcom-Bravo engcom-Bravo added Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Jul 17, 2019
@ghost ghost unassigned engcom-Bravo Jul 17, 2019
@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jul 17, 2019
@magento-engcom-team
Copy link
Contributor

✅ 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
Copy link

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.


@sergey-solo sergey-solo removed their assignment Jul 24, 2019
@sergey-solo
Copy link
Contributor

#23255

@PascalBrouwers
Copy link
Contributor

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

@engcom-Charlie
Copy link
Contributor

Hello @vovayatsyuk

Thank you for contribution and collaboration!

We are not able to reproduce this issue on the latest 2.4-develop branch by provided scenario.
Precondition:

  • only one store view
  • SingleStoreMode option in disabled

Steps

  1. Install Magento from latest 2.4-develop branch.
  2. Create cms block example for All Store views
  3. Create another cms block example for first store view only

AR: Block saved successfully

Could You take a look?

@vovayatsyuk
Copy link
Member Author

Looks like it was fixed in this commit: c8baed5

@engcom-Charlie
Copy link
Contributor

So we have to close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Cms Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests