From 4cd2f625f7068b50a6aacbef91ff66726d81005e Mon Sep 17 00:00:00 2001 From: Brandon Kelly Date: Sat, 14 Sep 2019 07:36:40 -0700 Subject: [PATCH 1/4] Fixed Updating search indexes job for Matrix blocks with relational fields --- CHANGELOG-v3.md | 1 + src/fields/Matrix.php | 17 +++-------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index bbf7265deac..e5923769315 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -7,6 +7,7 @@ - Fixed a bug where the "Edit Image" element action sometimes would be missing. ([#3349](https://github.com/craftcms/cms/issues/3349)) - Fixed a bug where querying for elements by their Lightswitch field value could only return elements that had been saved since the Lightswitch field was added. ([#4939](https://github.com/craftcms/cms/issues/4939)) - Fixed a bug where the "Update all" button was missing on the updates page. ([#4938](https://github.com/craftcms/cms/issues/4938)) +- Fixed a bug where the “Updating search indexes” job could fail when updating search indexes for a Matrix block that contained a relational field. ## 3.3.3 - 2019-09-12 diff --git a/src/fields/Matrix.php b/src/fields/Matrix.php index aa5d305cbe0..57e21cd568a 100644 --- a/src/fields/Matrix.php +++ b/src/fields/Matrix.php @@ -699,25 +699,14 @@ public function getSearchKeywords($value, ElementInterface $element): string $contentService = Craft::$app->getContent(); foreach ($value->all() as $block) { - $originalContentTable = $contentService->contentTable; - $originalFieldColumnPrefix = $contentService->fieldColumnPrefix; - $originalFieldContext = $contentService->fieldContext; - - $contentService->contentTable = $block->getContentTable(); - $contentService->fieldColumnPrefix = $block->getFieldColumnPrefix(); - $contentService->fieldContext = $block->getFieldContext(); - - foreach (Craft::$app->getFields()->getAllFields() as $field) { + $fields = Craft::$app->getFields()->getAllFields($block->getFieldContext()); + foreach ($fields as $field) { /** @var Field $field */ if ($field->searchable) { $fieldValue = $block->getFieldValue($field->handle); $keywords[] = $field->getSearchKeywords($fieldValue, $element); } } - - $contentService->contentTable = $originalContentTable; - $contentService->fieldColumnPrefix = $originalFieldColumnPrefix; - $contentService->fieldContext = $originalFieldContext; } return parent::getSearchKeywords($keywords, $element); @@ -984,7 +973,7 @@ public function afterElementRestore(ElementInterface $element) parent::afterElementRestore($element); } - + // Private Methods // ========================================================================= From 60a7777094d9ea78b851fd9164b2330c6645f0c8 Mon Sep 17 00:00:00 2001 From: Brandon Kelly Date: Sun, 15 Sep 2019 08:01:50 -0700 Subject: [PATCH 2/4] "Delete them" and "Keep them" Resolves #4943 --- CHANGELOG-v3.md | 3 +++ src/web/assets/assetindexes/dist/AssetIndexesUtility.js | 4 ++-- src/web/assets/assetindexes/dist/AssetIndexesUtility.min.js | 2 +- .../assets/assetindexes/dist/AssetIndexesUtility.min.js.map | 2 +- src/web/assets/cp/CpAsset.php | 2 ++ 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index e5923769315..424844c213c 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -2,6 +2,9 @@ ## Unreleased +### Changed +- Improved the button labels in the confirmation dialog that can appear after running the Asset Indexes utility. ([#4943](https://github.com/craftcms/cms/issues/4943)) + ### Fixed - Fixed a bug where asset queries’ `withTransforms` param wasn’t working for eager-loaded assets. ([#4931](https://github.com/craftcms/cms/issues/4931)) - Fixed a bug where the "Edit Image" element action sometimes would be missing. ([#3349](https://github.com/craftcms/cms/issues/3349)) diff --git a/src/web/assets/assetindexes/dist/AssetIndexesUtility.js b/src/web/assets/assetindexes/dist/AssetIndexesUtility.js index f4a9bbe6024..86d1b7c0a35 100644 --- a/src/web/assets/assetindexes/dist/AssetIndexesUtility.js +++ b/src/web/assets/assetindexes/dist/AssetIndexesUtility.js @@ -129,8 +129,8 @@ $body = $('
').appendTo($modal).html(data.confirm), $footer = $('