Skip to content

magento/magento2: Fixes for the schema cache.xsd #26933

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

Closed

Conversation

andrewbess
Copy link
Contributor

@andrewbess andrewbess commented Feb 19, 2020

Description (*)

This PR fixes the schema "cache.xsd" from Magento\Framework\Cache.

  1. The attribute "instance" has changed on required because if a developer won't be to use it new cache type will not be created;
  2. The parameters "label" and "description" have changed on required because of the class "Magento\Framework\App\Cache\TypeList" gets theirs without checking for existing. Please take a look at this code;
  3. Checking on unique of the type name has added;
  4. The configuration reader class has fixed for more informative during to run CLI commands;
  5. The class SchemaLocator has been fixed to check the cache configuration during configuration merging;
  6. The unnecessary checking has removed from the class TypeList;
  7. Unit tests have been covered.

Fixed Issues (if relevant)

Fixes: #26224

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Feb 19, 2020

Hi @andrewbess. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@magento-engcom-team magento-engcom-team added Component: Cache Release Line: 2.4 Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner labels Feb 19, 2020
@magento-deployment-service
Copy link

Hi @m2-assistant[bot] Here is your new Magento Instance: https://pr-26933.magento-testing-service.engineering
Admin access: https://pr-26933.magento-testing-service.engineering/admin_9c20
Login: 6a81d57b , Password: 34181a6d3f4e

@andrewbess andrewbess requested a review from rogyar February 20, 2020 16:51
@swnsma swnsma self-requested a review February 20, 2020 18:46
Copy link
Contributor

@swnsma swnsma left a comment

Choose a reason for hiding this comment

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

Hi @andrewbess!
Thank you for your contribution!
Could you please add unit tests to check new schema validation?
Maybe, we also should refactor the class \Magento\Framework\App\Cache\TypeList as 'instance' will become a required parameter? We may simplify some checks here.

Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

Please see following review details: #26933 (review)

@ghost ghost assigned ihor-sviziev Mar 4, 2020
@ihor-sviziev ihor-sviziev removed their assignment Mar 4, 2020
@andrewbess andrewbess force-pushed the improvement/cache-schema branch 4 times, most recently from 641b94e to 1b7d5f9 Compare March 13, 2020 14:49
@andrewbess
Copy link
Contributor Author

Hi @andrewbess!
Thank you for your contribution!
Could you please add unit tests to check new schema validation?
Maybe, we also should refactor the class \Magento\Framework\App\Cache\TypeList as 'instance' will become a required parameter? We may simplify some checks here.

Hello @swnsma
Thank you for review.
I added the changes.
There are additional changes for schema, tests, additional changes for TypeList in the PR.
Also, I have changed description of PR.
Please recheck.
Thank you in advance.

{
try {
return parent::read($scope);
} catch (\Magento\Framework\Exception\LocalizedException $e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

May I ask you why do we need to transform this localized exception and throw once again?

Thank you

Copy link
Contributor Author

@andrewbess andrewbess Mar 15, 2020

Choose a reason for hiding this comment

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

Hello @rogyar.
Thank you for your remark.
Previously, I have added the render-method that prepares an error message to output error messages correctly.
But it caused other problems.
I have removed new methods.
Please recheck.
Thank you in advance.

@ghost ghost assigned rogyar Mar 14, 2020
Copy link
Contributor

@swnsma swnsma left a comment

Choose a reason for hiding this comment

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

Please check my comment.
Would you be so kind to check strict types declaration, type hints and add 'declare(strict_types=1);' to changed files.
Thank you!

*/
namespace Magento\Framework\Cache\Test\Unit;

class XsdTest extends \PHPUnit\Framework\TestCase
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @andrewbess,

I have discovered that we already have bunch of tests which test *.xsd files.
They are located in Magento\Test\Integrity namespace.
Could I ask you to move your your tests under this namespace to keep consistency in tests structure?
Please check \Magento\Test\Integrity\Magento\Widget\WidgetConfigTest for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @swnsma.
I have moved tests by the suggested path.
Also, I added declaration strict types where it is required.
Please recheck.
Thank you in advance.

@andrewbess andrewbess force-pushed the improvement/cache-schema branch from 1b7d5f9 to 56b1391 Compare March 15, 2020 09:32
@andrewbess andrewbess requested a review from rogyar March 15, 2020 11:22
@andrewbess andrewbess requested a review from swnsma March 15, 2020 11:22
@andrewbess andrewbess force-pushed the improvement/cache-schema branch 2 times, most recently from dfe05e5 to dcf42e9 Compare March 16, 2020 08:10
Copy link
Contributor

@swnsma swnsma left a comment

Choose a reason for hiding this comment

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

Hi @andrewbess!
Thank you for your contribution!
Could you please check my notices?

/**
* @var \Magento\Framework\TestFramework\Unit\Utility\XsdValidator
*/
protected $_xsdValidator;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please
protected -> private
$_xsdValidator -> $xsdValidator

@andrewbess andrewbess force-pushed the improvement/cache-schema branch from dcf42e9 to 1f8f2a0 Compare March 16, 2020 09:25
@andrewbess
Copy link
Contributor Author

Closed in favor of #27307

@andrewbess andrewbess closed this Mar 17, 2020
@m2-assistant
Copy link

m2-assistant bot commented Mar 17, 2020

Hi @andrewbess, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@andrewbess andrewbess deleted the improvement/cache-schema branch March 17, 2020 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Cache Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner Progress: needs update Release Line: 2.4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache type without "instance" causes exception when disabling the module through "Cache Management" in the backend
5 participants