From 48aa8831621aaf4949b1c865c4ef9d39cf5b3f91 Mon Sep 17 00:00:00 2001 From: Volodymyr Hadomskyi Date: Wed, 17 May 2023 22:21:05 +0200 Subject: [PATCH] Added fallback for block elements without a created structure to fix content provider ENG-7649 --- CHANGELOG.md | 4 ++++ composer.json | 2 +- .../providers/field/ElementQueryContentProvider.php | 10 ++++++++++ .../controllers/job/PostJobRetryControllerCest.php | 2 -- tests/integration/modules/SendJobToConnectorCest.php | 6 ------ 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 221073de..e88628cf 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 3.5.3 - 2023-05-18 +### Fixed +- Added fallback for block elements without a created structure to fix content provider + ## 3.5.2 - 2023-05-17 ### Changed - Updated error message for failed jobs after retries diff --git a/composer.json b/composer.json index 9ae83467..5f8fd841 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "lilt/craft-lilt-plugin", "description": "The Lilt plugin makes it easy for you to send content to Lilt for translation right from within Craft CMS.", "type": "craft-plugin", - "version": "3.5.2", + "version": "3.5.3", "keywords": [ "craft", "cms", diff --git a/src/services/providers/field/ElementQueryContentProvider.php b/src/services/providers/field/ElementQueryContentProvider.php index 1be1b367..7b1854b8 100644 --- a/src/services/providers/field/ElementQueryContentProvider.php +++ b/src/services/providers/field/ElementQueryContentProvider.php @@ -33,6 +33,16 @@ public function provide(ProvideContentCommand $provideContentCommand): array */ $blockElements = $matrixBlockQuery->all(); + //Fallback for neo block elements without a created structure + if (count($blockElements) === 0 && get_class($field) === CraftliltpluginParameters::BENF_NEO_FIELD) { + /** @var \benf\neo\elements\db\BlockQuery $matrixBlockQuery */ + $matrixBlockQuery->withStructure = false; + $matrixBlockQuery->orderBy = ''; + + $blockElements = $matrixBlockQuery->orderBy([])->all(); + } + + foreach ($blockElements as $blockElement) { $blockId = $blockElement->getId(); diff --git a/tests/integration/controllers/job/PostJobRetryControllerCest.php b/tests/integration/controllers/job/PostJobRetryControllerCest.php index f3ea9fb6..759a092d 100644 --- a/tests/integration/controllers/job/PostJobRetryControllerCest.php +++ b/tests/integration/controllers/job/PostJobRetryControllerCest.php @@ -45,8 +45,6 @@ public function _fixtures(): array */ public function testRetrySuccess(IntegrationTester $I, $scenario): void { - $scenario->skip('Neo field is not getting updated and missing in source content'); - $I->amLoggedInAs( Craft::$app->getUsers()->getUserById(1) ); diff --git a/tests/integration/modules/SendJobToConnectorCest.php b/tests/integration/modules/SendJobToConnectorCest.php index 40e36eed..a491e10f 100644 --- a/tests/integration/modules/SendJobToConnectorCest.php +++ b/tests/integration/modules/SendJobToConnectorCest.php @@ -58,8 +58,6 @@ private function getController(): PostCreateJobController */ public function testCreateJob(IntegrationTester $I, $scenario): void { - $scenario->skip('Neo field is not getting updated and missing in source content'); - $user = Craft::$app->getUsers()->getUserById(1); $I->amLoggedInAs($user); @@ -182,8 +180,6 @@ public function testCreateJob(IntegrationTester $I, $scenario): void public function testSendCopySourceFlow(IntegrationTester $I, $scenario): void { - $scenario->skip('Neo field is not getting updated and missing in source content'); - $user = Craft::$app->getUsers()->getUserById(1); $I->amLoggedInAs($user); @@ -300,8 +296,6 @@ public function testSendCopySourceFlow(IntegrationTester $I, $scenario): void */ public function testCreateJobWithUnexpectedStatusFromConnector(IntegrationTester $I, $scenario): void { - $scenario->skip('Neo field is not getting updated and missing in source content'); - $element = Entry::find() ->where(['authorId' => 1]) ->orderBy(['id' => SORT_DESC])