Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Added validation for store id in CMS Block #870

Closed
wants to merge 7 commits into from

Conversation

Rus0
Copy link
Contributor

@Rus0 Rus0 commented Aug 28, 2019

Description (*)

Adding a filter for store id in the blocks, using the store send in the headers

Fixed Issues (if relevant)

  1. magento/graphql-ce#691: cmsBlocks that has scope limited to specific Store View can be seen on other Store Views in case there are Blocks with identical identifiers on both Store Views

Manual testing scenarios (*)

  1. All the steps in the ticket #691

Questions or comments

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)

@Rus0 Rus0 requested a review from lenaorobei August 29, 2019 21:44
Copy link
Contributor

@lenaorobei lenaorobei 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 my comments.

@@ -5,6 +5,7 @@
"require": {
"php": "~7.1.3||~7.2.0||~7.3.0",
"magento/framework": "*",
"magento/module-store": "*",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"magento/module-store": "*",
"magento/module-store": "*",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

??? I don't see any changes or comment @lenaorobei

Copy link
Contributor

Choose a reason for hiding this comment

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

magento/module-store is redundant dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I don't set it, I get the error: Module Magento\CmsGraphQl has undeclared dependencies: hard [Magento\Store]

Copy link
Contributor

@lenaorobei lenaorobei 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 address comments.

@lenaorobei
Copy link
Contributor

@magento run Functional Tests build

@magento-engcom-team
Copy link
Contributor

Hi @lenaorobei, thank you for the review.
ENGCOM-5826 has been created to process this Pull Request
✳️ @lenaorobei, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@magento-engcom-team
Copy link
Contributor

Hi @lenaorobei, thank you for the review.
ENGCOM-5826 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

Hi @lenaorobei, thank you for the review.
ENGCOM-5826 has been created to process this Pull Request

@TomashKhamlai
Copy link
Contributor

Could you please merge the latest mainline to this PR?

In production mode, I am getting this error on schema loading

"debugMessage":"User Deprecated Functionality: GraphQL\\Type\\Definition\\Type::getInternalTypes is deprecated. Use Type::getStandardTypes()

I have seen this error several times on branches that are oudated.

@magento-cicd2
Copy link
Contributor

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ Rus0
✅ lenaorobei
❌ devilbox


devilbox seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.

Signed-off-by: Tomash Khamlai <tomash.khamlai@gmail.com>
@TomashKhamlai
Copy link
Contributor

TomashKhamlai commented Sep 27, 2019

Well done! 👍

Checked. Works as expected

✔️ The title is according to Store headers
✔️ The content is according to Store headers
✔️ Variables which got values in the Store View scope are displayed as expected
✔️ Variables which were set in the global scope are displayed as expected

The problem

❌ If the block has the scope All store views it is not found.

Details of the problem

Request 1

query showCmsBlock(
  $identifiers: [String]
) {
  storeConfig {
    code
  }
  cmsBlocks(
    identifiers: $identifiers
  ) {
    items {
      content
      title
      identifier
    }
  }
}

Headers 1

No headers

Variables 1

{
  "identifiers": ["test-block-2"]
}

Response 1

{
  "errors": [
    {
      "message": "The CMS block with the \"test-block-2\" ID doesn't exist.",
      "extensions": {
        "category": "graphql-no-such-entity"
      },
      "locations": [
        {
          "line": 6,
          "column": 5
        }
      ],
      "path": [
        "cmsBlocks",
        "items",
        0
      ]
    }
  ],
  "data": {
    "storeConfig": {
      "code": "default"
    },
    "cmsBlocks": {
      "items": [
        null
      ]
    }
  }
}

Request 2

query showCmsBlock(
  $identifiers: [String]
) {
  storeConfig {
    code
  }
  cmsBlocks(
    identifiers: $identifiers
  ) {
    items {
      content
      title
      identifier
    }
  }
}

Headers 2

{
  "Store": "germstv"
}

Variables 2

{
  "identifiers": ["test-block-2"]
}

Response 2

{
  "errors": [
    {
      "message": "The CMS block with the \"test-block-2\" ID doesn't exist.",
      "extensions": {
        "category": "graphql-no-such-entity"
      },
      "locations": [
        {
          "line": 6,
          "column": 5
        }
      ],
      "path": [
        "cmsBlocks",
        "items",
        0
      ]
    }
  ],
  "data": {
    "storeConfig": {
      "code": "germstv"
    },
    "cmsBlocks": {
      "items": [
        null
      ]
    }
  }
}

Blocks enabled

image

Block that was requested

image

Copy link
Contributor

@lenaorobei lenaorobei left a comment

Choose a reason for hiding this comment

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

@Rus0, could you please address found issues?

@Rus0
Copy link
Contributor Author

Rus0 commented Oct 1, 2019 via email

@lenaorobei
Copy link
Contributor

@Rus0 unfortunately, I need to close this PR since there is no activity. Please feel free to reopen if you want to continue working on it. Thank you.

@lenaorobei lenaorobei closed this Oct 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants