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

Bugfix/13212 graphql enable for site #13214

Merged
merged 6 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/gql/interfaces/elements/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
5 changes: 5 additions & 0 deletions src/gql/resolvers/mutations/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down