From f7acd8619183f1e9f13987dbb8b2df9dc99bdbb4 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Wed, 13 Apr 2022 17:55:15 +0200 Subject: [PATCH 1/2] Fix validation of modified sparse ASTs --- CHANGELOG.md | 5 +++++ src/Validator/ValidationContext.php | 13 ++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe1fd7f5d..764e795ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ #### Unreleased +#### 14.11.6 + +Fixed: +- Fix validation of modified sparse ASTs + #### 14.11.5 Fixed: diff --git a/src/Validator/ValidationContext.php b/src/Validator/ValidationContext.php index 549053eb5..0b25ff9a4 100644 --- a/src/Validator/ValidationContext.php +++ b/src/Validator/ValidationContext.php @@ -180,16 +180,15 @@ public function getFragmentSpreads(HasSelectionSet $node) : array while (count($setsToVisit) > 0) { $set = array_pop($setsToVisit); - for ($i = 0, $selectionCount = count($set->selections); $i < $selectionCount; $i++) { - $selection = $set->selections[$i]; + foreach ($set->selections as $selection) { if ($selection instanceof FragmentSpreadNode) { $spreads[] = $selection; - } elseif ($selection instanceof FieldNode || $selection instanceof InlineFragmentNode) { - if ($selection->selectionSet) { - $setsToVisit[] = $selection->selectionSet; - } } else { - throw InvariantViolation::shouldNotHappen(); + assert($selection instanceof FieldNode || $selection instanceof InlineFragmentNode); + $selectionSet = $selection->selectionSet; + if ($selectionSet !== null) { + $setsToVisit[] = $selectionSet; + } } } } From 36959d068eda85cd048daadee14e436963cc2ab6 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Wed, 13 Apr 2022 17:58:56 +0200 Subject: [PATCH 2/2] shivammathur/setup-php@2.18.1 --- .github/workflows/ci-build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 17321f5fd..93b2711e5 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -24,11 +24,12 @@ jobs: - uses: actions/checkout@v2 - name: Install PHP - uses: shivammathur/setup-php@2.9.0 + uses: shivammathur/setup-php@2.18.1 with: php-version: ${{ matrix.php }} coverage: none extensions: json, mbstring + - name: Get Composer Cache Directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)"