Skip to content

Commit

Permalink
Merge branch '5.0' into bugfix/subpath-urls
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
brandonkelly committed Feb 15, 2024
2 parents c9ed211 + 85d2563 commit a4fb1b5
Show file tree
Hide file tree
Showing 84 changed files with 1,410 additions and 577 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/BUG-REPORT-V3.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Bug ReportCraft 3
name: 'Bug Report: Craft 3'
description: Report an issue or unexpected behavior pertaining to Craft 3
title: '[3.x]: '
labels:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/BUG-REPORT-V4.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Bug ReportCraft 4
name: 'Bug Report: Craft 4'
description: Report an issue or unexpected behavior pertaining to Craft 4
title: '[4.x]: '
labels:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/BUG-REPORT-V5.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Bug ReportCraft 5
name: 'Bug Report: Craft 5'
description: Report an issue or unexpected behavior pertaining to Craft 5
title: '[5.x]: '
labels:
Expand Down
33 changes: 27 additions & 6 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
blank_issues_enabled: false
contact_links:
- name: Feature Request
url: https://github.com/craftcms/cms/discussions/new?category=ideas
about: Start a new discussion about your idea
- name: Documentation
url: https://docs.craftcms.com/
url: https://craftcms.com/docs
about: Read the official documentation
- name: Knowledge Base
url: https://craftcms.com/knowledge-base
about: Find answers to common problems
about: Find official answers to common problems
- name: Developer Support Services
url: https://craftcms.com/support-services
about: Priority developer support from the team that makes Craft
- name: Craft Discord
url: https://craftcms.com/discord
about: Meet the community
- name: Stack Exchange
- name: Craft Stack Exchange
url: https://craftcms.stackexchange.com/
about: Get help and help others
- name: 'Feature Request: Craft CMS'
url: https://github.com/craftcms/cms/discussions/new?category=ideas
about: Make a feature request or enhancement for Craft CMS
- name: 'Feature Request: Craft Console / Plugin Store'
url: https://github.com/craftcms/console/discussions/new?category=ideas
about: Make a feature request or enhancement for Craft Console or the Plugin Store
- name: 'Feature Request: Craft Cloud'
url: https://github.com/craftcms/cloud/discussions/new?category=ideas
about: Make a feature request or enhancement for Craft Cloud
- name: 'Feature Request: Craft Commerce'
url: https://github.com/craftcms/commerce/discussions/new?category=ideas
about: Make a feature request or enhancement for Craft Commerce
- name: 'Bug Report: Craft CMS'
url: https://github.com/craftcms/cms/issues/new/choose
about: Create a bug report for Craft CMS
- name: 'Bug Report: Craft Console / Plugin Store'
url: https://github.com/craftcms/console/issues/new/choose
about: Create a bug report for Craft Console or the Plugin Store
- name: 'Bug Report: Craft Cloud'
url: https://craftcms.com/contact
about: Create a bug report for Craft Cloud
- name: 'Bug Report: Craft Commerce'
url: https://github.com/craftcms/commerce/issues/new/choose
about: Create a bug report for Craft Commerce
7 changes: 7 additions & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@
- Entry queries now have `field`, `fieldId`, `primaryOwner`, `primaryOwnerId`, `owner`, `ownerId`, `allowOwnerDrafts`, and `allowOwnerRevisions` params.
- Entry queries’ `authorId` params now support passing multiple IDs prefixed with `and`, to fetch entries with multiple listed authors.
- User queries now have an `authorOf` param.
- Nested addresses are now cached by their field ID, and address queries now register cache tags based on their `field` and `fieldId` params.
- Nested entries are now cached by their field ID, and entry queries now register cache tags based on their `field` and `fieldId` params.
- GraphQL schemas can now include queries and mutations for nested entries (e.g. within Matrix or CKEditor fields) directly. ([#14366](https://github.com/craftcms/cms/pull/14366))
- Added the `fieldId`, `fieldHandle`, `ownerId`, and `sortOrder` entry GraphQL fields. ([#14366](https://github.com/craftcms/cms/pull/14366))
- Entries’ GraphQL type names are now formatted as `<entryTypeHandle>_Entry`, and are no longer prefixed with their section’s handle. (That goes for Matrix-nested entries as well.)
- Entries now have `author` and `authorIds` GraphQL field.
- Matrix fields’ GraphQL mutation types now expect nested entries to be defined by an `entries` field rather than `blocks`.
Expand Down Expand Up @@ -357,7 +361,9 @@
- Added `craft\services\Entries::refreshEntryTypes()`.
- Added `craft\services\Entries::saveSection()`.
- Added `craft\services\Fields::$fieldContext`, which replaces `craft\services\Content::$fieldContext`.
- Added `craft\services\Fields::EVENT_REGISTER_NESTED_ENTRY_FIELD_TYPES`.
- Added `craft\services\Fields::getAllLayouts()`.
- Added `craft\services\Fields::getNestedEntryFieldTypes()`.
- Added `craft\services\Gql::defineContentArgumentsForFieldLayouts()`.
- Added `craft\services\Gql::defineContentArgumentsForFields()`.
- Added `craft\services\Gql::getOrSetContentArguments()`.
Expand Down Expand Up @@ -443,6 +449,7 @@
- `craft\helpers\StringHelper::toString()` now supports backed enums.
- `craft\i18n\I18N::getPrimarySiteLocale()` is now deprecated. `craft\models\Site::getLocale()` should be used instead.
- `craft\i18n\I18N::getPrimarySiteLocaleId()` is now deprecated. `craft\models\Site::$language` should be used instead.
- `craft\models\FieldLayout::getField()` and `isFieldIncluded()` now now have a `$filter` argument rather than `$attribute`, and it can be set to a callable.
- `craft\models\Section::$propagationMethod` now has a type of `craft\enums\PropagationMethod`.
- `craft\services\AssetIndexer::indexFileByListing()` now has a `$volume` argument in place of `$volumeId`.
- `craft\services\AssetIndexer::indexFolderByListing()` now has a `$volume` argument in place of `$volumeId`.
Expand Down
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,32 @@
- Restored the “Preview” and “Edit Image” buttons on asset image previews. ([#14333](https://github.com/craftcms/cms/discussions/14333))
- Improved the accessibility of the global sidebar. ([#14335](https://github.com/craftcms/cms/pull/14335))
- Improved the contrast of the Dev Mode caution tape indicator. ([#14336](https://github.com/craftcms/cms/pull/14336))
- GraphQL schemas can now include queries and mutations for nested entries (e.g. within Matrix or CKEditor fields) directly. ([#14366](https://github.com/craftcms/cms/pull/14366))
- Added the `fieldId`, `fieldHandle`, `ownerId`, and `sortOrder` entry GraphQL fields. ([#14366](https://github.com/craftcms/cms/pull/14366))
- Nested addresses are now cached by their field ID, and address queries now register cache tags based on their `field` and `fieldId` params.
- Nested entries are now cached by their field ID, and entry queries now register cache tags based on their `field` and `fieldId` params.
- Added `craft\services\Fields::EVENT_REGISTER_NESTED_ENTRY_FIELD_TYPES`.
- Added `craft\services\Fields::getNestedEntryFieldTypes()`.
- Added `craft\services\ProjectConfig::EVENT_AFTER_WRITE_YAML_FILES`. ([#14365](https://github.com/craftcms/cms/discussions/14365))
- Added `craft\services\Relations::deleteLeftoverRelations()`. ([#13956](https://github.com/craftcms/cms/issues/13956))
- Added `craft\services\Search::shouldCallSearchElements()`. ([#14293](https://github.com/craftcms/cms/issues/14293))
- `craft\behaviors\SessionBehavior::setSuccess()` and `getSuccess()` use the `success` flash key now, rather than `notice`. ([#14345](https://github.com/craftcms/cms/pull/14345))
- `craft\helpers\Assets::generateUrl()` no longer has an `$fs` argument. ([#14353](https://github.com/craftcms/cms/pull/14353))
- `craft\models\FieldLayout::getField()` and `isFieldIncluded()` now now have a `$filter` argument rather than `$attribute`, and it can be set to a callable.
- Exception response data no longer includes an `error` key with the exception message. `message` should be used instead. ([#14346](https://github.com/craftcms/cms/pull/14346))
- Fixed a bug where read/write splitting was always getting disabled for GraphQL POST requests. ([#14324](https://github.com/craftcms/cms/issues/14324))
- Relations for fields that are no longer included in an element’s field layout are now deleted after element save. ([#13956](https://github.com/craftcms/cms/issues/13956))
- Assets fields’ selection modals now open to the last-viewed location by default, if their Default Upload Location doesn’t specify a subpath. ([#14382](https://github.com/craftcms/cms/pull/14382))
- Fixed an error that occurred when adding a new block to a Matrix field with an overridden handle. ([#14350](https://github.com/craftcms/cms/issues/14350))
- Fixed a bug where opening a disclosure menu wasn’t hiding others. ([#14354](https://github.com/craftcms/cms/issues/14354))
- Fixed a bug where non-global custom fields were being shown on the Fields index page when searching. ([#14344](https://github.com/craftcms/cms/issues/14344))
- Fixed a bug where component slideouts would open when long-pressing on a component’s action menu button or drag handle within a component select input.
- Fixed various issues with Tags fields. ([#14356](https://github.com/craftcms/cms/issues/14356), [#14359](https://github.com/craftcms/cms/pull/14359))
- Fixed a bug where it was possible to include single-instance fields multiple times in a field layout. ([#14352](https://github.com/craftcms/cms/issues/14352))
- Fixed a bug where read/write splitting was always getting disabled for GraphQL POST requests. ([#14324](https://github.com/craftcms/cms/issues/14324))
- Fixed a bug where GraphQL schema edit pages could include empty category headings.
- Fixed a bug where asset slideouts weren’t showing validation errors on the Filename field. ([#14329](https://github.com/craftcms/cms/issues/14329))
- Fixed a bug where element slideouts would open when long-pressing on an element’s “Remove” button within an element select input.
- Fixed a bug where relations weren’t getting deleted when an element was deleted for a site. ([#14347](https://github.com/craftcms/cms/issues/14347))

## 5.0.0-beta.1 - 2024-02-08

Expand Down
5 changes: 2 additions & 3 deletions packages/craftcms-vue/admintable/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1150,11 +1150,10 @@
background-color: #fff;
border-top: 1px solid #f3f7fc;
bottom: 0;
margin-bottom: -14px;
margin-bottom: calc(var(--xl) * -1);
margin-top: 14px;
padding-bottom: 14px;
padding-top: 14px;
position: sticky;
min-height: 44px;
}
.vue-admin-tablepane + .vue-admin-table-footer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
type: Object,
default: () => {
return {
singular: Craft.t('app', 'Item'),
plural: Craft.t('app', 'Items'),
singular: Craft.t('app', 'item'),
plural: Craft.t('app', 'items'),
};
},
},
Expand Down
5 changes: 5 additions & 0 deletions src/base/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -5693,6 +5693,11 @@ public function afterPropagate(bool $isNew): void
$field->afterElementPropagate($this, $isNew);
}

// Delete relations that don’t belong to a relational field on the element's field layout
if (!ElementHelper::isDraftOrRevision($this)) {
Craft::$app->getRelations()->deleteLeftoverRelations($this);
}

// Trigger an 'afterPropagate' event
if ($this->hasEventHandlers(self::EVENT_AFTER_PROPAGATE)) {
$this->trigger(self::EVENT_AFTER_PROPAGATE, new ModelEvent([
Expand Down
41 changes: 41 additions & 0 deletions src/elements/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use CommerceGuys\Addressing\AddressFormat\AddressField;
use CommerceGuys\Addressing\AddressInterface;
use CommerceGuys\Addressing\Subdivision\SubdivisionUpdater;
use Craft;
use craft\base\Element;
use craft\base\NameTrait;
Expand Down Expand Up @@ -569,6 +570,46 @@ public function defineRules(): array
return $rules;
}

/**
* @inheritdoc
*/
protected function cacheTags(): array
{
$tags = [];

if (isset($this->fieldId)) {
$tags[] = "field:$this->fieldId";
}

return $tags;
}

/**
* @inheritdoc
*/
public function beforeSave(bool $isNew): bool
{
// commerceguys/addressing 2.0.x - remap changed subdivision IDs
// update the subdivision ID to its ISO code where available
if (isset($this->countryCode)) {
if (isset($this->administrativeArea)) {
$this->administrativeArea = SubdivisionUpdater::updateValue(
$this->countryCode,
$this->administrativeArea,
);
}
// Andorra is the only country with remapped localities.
if ($this->countryCode == 'AD' && isset($this->locality)) {
$this->locality = SubdivisionUpdater::updateValue(
$this->countryCode,
$this->locality,
);
}
}

return parent::beforeSave($isNew);
}

/**
* @inheritdoc
* @throws InvalidConfigException
Expand Down
1 change: 1 addition & 0 deletions src/elements/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -2740,6 +2740,7 @@ protected function metaFieldsHtml(bool $static): string
return implode("\n", [
Cp::textFieldHtml([
'label' => Craft::t('app', 'Filename'),
'attribute' => 'newLocation',
'id' => 'new-filename',
'name' => 'newFilename',
'value' => $this->_filename,
Expand Down
2 changes: 2 additions & 0 deletions src/elements/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,8 @@ protected function cacheTags(): array

if (isset($this->sectionId)) {
$tags[] = "section:$this->sectionId";
} elseif (isset($this->fieldId)) {
$tags[] = "field:$this->fieldId";
}

return $tags;
Expand Down
7 changes: 7 additions & 0 deletions src/elements/db/AddressQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -1391,11 +1391,18 @@ protected function cacheTags(): array
{
$tags = [];

if ($this->fieldId) {
foreach ($this->fieldId as $fieldId) {
$tags[] = "field:$fieldId";
}
}

if ($this->primaryOwnerId) {
foreach ($this->primaryOwnerId as $ownerId) {
$tags[] = "element::$ownerId";
}
}

if ($this->ownerId) {
foreach ($this->ownerId as $ownerId) {
$tags[] = "element::$ownerId";
Expand Down
8 changes: 5 additions & 3 deletions src/elements/db/ElementQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -2892,9 +2892,11 @@ private function _applySearchParam(): void
return;
}

if (isset($this->orderBy['score'])) {
$searchService = Craft::$app->getSearch();

if (isset($this->orderBy['score']) || $searchService->shouldCallSearchElements($this)) {
// Get the scored results up front
$searchResults = Craft::$app->getSearch()->searchElements($this);
$searchResults = $searchService->searchElements($this);

if ($this->orderBy['score'] === SORT_ASC) {
$searchResults = array_reverse($searchResults, true);
Expand All @@ -2920,7 +2922,7 @@ private function _applySearchParam(): void
$this->subQuery->andWhere(['elements.id' => array_keys($searchResults)]);
} else {
// Just filter the main query by the search query
$searchQuery = Craft::$app->getSearch()->createDbQuery($this->search, $this);
$searchQuery = $searchService->createDbQuery($this->search, $this);

if ($searchQuery === false) {
throw new QueryAbortedException();
Expand Down
6 changes: 6 additions & 0 deletions src/elements/db/EntryQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -1641,12 +1641,18 @@ protected function cacheTags(): array
foreach ($this->sectionId as $sectionId) {
$tags[] = "section:$sectionId";
}
} elseif ($this->fieldId) {
foreach ($this->fieldId as $fieldId) {
$tags[] = "field:$fieldId";
}
}

if ($this->primaryOwnerId) {
foreach ($this->primaryOwnerId as $ownerId) {
$tags[] = "element::$ownerId";
}
}

if ($this->ownerId) {
foreach ($this->ownerId as $ownerId) {
$tags[] = "element::$ownerId";
Expand Down
16 changes: 16 additions & 0 deletions src/fields/BaseRelationField.php
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,22 @@ public function afterElementSave(ElementInterface $element, bool $isNew): void
parent::afterElementSave($element, $isNew);
}

/**
* @inheritdoc
*/
public function afterElementDeleteForSite(ElementInterface $element): void
{
if ($this->localizeRelations) {
Db::delete(DbTable::RELATIONS, [
'fieldId' => $this->id,
'sourceSiteId' => $element->siteId,
'sourceId' => $element->id,
]);
}

parent::afterElementDeleteForSite($element);
}

/**
* Normalizes the available sources into select input options.
*
Expand Down
1 change: 1 addition & 0 deletions src/fields/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ protected function defineRules(): array
$rules = parent::defineRules();
$rules[] = [['defaultValue', 'min', 'max'], 'number'];
$rules[] = [['decimals', 'size'], 'integer'];

$rules[] = [
['max'],
'compare',
Expand Down
10 changes: 10 additions & 0 deletions src/fields/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ protected function inputHtml(mixed $value, ?ElementInterface $element, bool $inl
return '<p class="error">' . Craft::t('app', 'This field is not set to a valid source.') . '</p>';
}

/**
* @inheritdoc
*/
protected function supportedViewModes(): array
{
return [
'list' => Craft::t('app', 'List'),
];
}

/**
* @inheritdoc
*/
Expand Down
20 changes: 20 additions & 0 deletions src/gql/arguments/elements/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ public static function getArguments(): array
'type' => Type::listOf(QueryArgument::getType()),
'description' => 'Narrows the query results based on the sections the entries belong to, per the sections’ IDs.',
],
'field' => [
'name' => 'field',
'type' => Type::listOf(Type::string()),
'description' => 'Narrows the query results based on the field the entries are contained by.',
],
'fieldId' => [
'name' => 'fieldId',
'type' => Type::listOf(QueryArgument::getType()),
'description' => 'Narrows the query results based on the field the entries are contained by, per the fields’ IDs.',
],
'primaryOwnerId' => [
'name' => 'primaryOwnerId',
'type' => Type::listOf(QueryArgument::getType()),
'description' => 'Narrows the query results based on the primary owner element of the entries, per the owners’ IDs.',
],
'ownerId' => [
'name' => 'ownerId',
'type' => Type::listOf(QueryArgument::getType()),
'description' => 'Narrows the query results based on the owner element of the entries, per the owners’ IDs.',
],
'type' => [
'name' => 'type',
'type' => Type::listOf(Type::string()),
Expand Down
Loading

0 comments on commit a4fb1b5

Please sign in to comment.