diff --git a/CHANGELOG.md b/CHANGELOG.md index eb363796523..1c5e6aad31f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,13 @@ ## Unreleased +- Added the `enabledForSite` field for entries queried via GraphQL. ([#13214](https://github.com/craftcms/cms/pull/13214)) - Improved `craft\helpers\FileHelper::getExtensionByMimeType()` for some ambiguous, web-friendly MIME types. - Fixed a bug where reverting an entry’s content from a revision could omit some Matrix blocks. - Fixed an error that could occur when adding a new site to an entry which contained Matrix blocks, if the same site had been added and removed previously. - Fixed a bug where Matrix blocks nested within Neo or Super Table fields could be omitted when propagating an entry to a new site. ([#13207](https://github.com/craftcms/cms/issues/13207)) - Fixed a bug where `craft\web\View::registerTwigExtension()` could throw an exception if Twig was already initialized. ([#13208](https://github.com/craftcms/cms/issues/13208)) +- Fixed a bug where entries mutated via GraphQL weren’t becoming globally enabled if `enabled` was set to `true`. ([#13214](https://github.com/craftcms/cms/pull/13214)) - Fixed two XSS vulnerabilities. ## 4.4.11 - 2023-05-15 diff --git a/src/gql/interfaces/elements/Entry.php b/src/gql/interfaces/elements/Entry.php index 21f7eeed716..a7cdd6dc952 100644 --- a/src/gql/interfaces/elements/Entry.php +++ b/src/gql/interfaces/elements/Entry.php @@ -182,6 +182,11 @@ public static function getFieldDefinitions(): array return $childrenComplexity + GqlService::GRAPHQL_COMPLEXITY_NPLUS1 * (int)!empty($args); }, ], + 'enabledForSite' => [ + 'name' => 'enabledForSite', + 'type' => Type::boolean(), + 'description' => 'Whether the element is enabled for the site.', + ], ]), self::getName()); } diff --git a/src/gql/resolvers/mutations/Entry.php b/src/gql/resolvers/mutations/Entry.php index 4ea5ed5c08c..2f8714a4d28 100644 --- a/src/gql/resolvers/mutations/Entry.php +++ b/src/gql/resolvers/mutations/Entry.php @@ -54,6 +54,11 @@ public function saveEntry(mixed $source, array $arguments, mixed $context, Resol if (array_key_exists('enabled', $arguments)) { if (!empty($arguments['siteId'])) { $entry->setEnabledForSite([$arguments['siteId'] => $arguments['enabled']]); + // Set the global status to true if it's currently disabled, + // and we're enabling entry for a site + if ($arguments['enabled'] && !$entry->enabled) { + $entry->enabled = $arguments['enabled']; + } } else { $entry->enabled = $arguments['enabled']; }