Skip to content

Commit 4e585fc

Browse files
committed
Merge branch 'craft-3' of https://github.com/verbb/super-table into craft-3
2 parents 62b3b5a + 1f3c78f commit 4e585fc

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Changed
6+
- Super Table now requires Craft 3.1.13 or later.
7+
38
## 2.1.8 - 2019-02-18
49

510
### Fixed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626
],
2727
"require": {
28-
"craftcms/cms": "^3.1.2"
28+
"craftcms/cms": "^3.1.13"
2929
},
3030
"repositories": [
3131
{

src/services/SuperTableService.php

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace verbb\supertable\services;
33

4+
use craft\db\Table;
45
use verbb\supertable\elements\db\SuperTableBlockQuery;
56
use verbb\supertable\elements\SuperTableBlockElement;
67
use verbb\supertable\errors\SuperTableBlockTypeNotFoundException;
@@ -312,20 +313,17 @@ public function handleChangedBlockType(ConfigEvent $event)
312313
return;
313314
}
314315

315-
ProjectConfigHelper::ensureAllFieldsProcessed();
316-
317-
// Ensure all Matrix blocks are processed
318-
$projectConfig = Craft::$app->getProjectConfig();
319-
$allBlocks = $projectConfig->get(\craft\services\Matrix::CONFIG_BLOCKTYPE_KEY, true) ?? [];
320-
321-
foreach ($allBlocks as $blockUid => $blockData) {
322-
$projectConfig->processConfigChanges(\craft\services\Matrix::CONFIG_BLOCKTYPE_KEY . '.' . $blockUid);
323-
}
324-
325316
$blockTypeUid = $event->tokenMatches[0];
326317
$data = $event->newValue;
327318
$previousData = $event->oldValue;
328319

320+
// Make sure the field has been synced
321+
$fieldId = Db::idByUid(Table::FIELDS, $data['field']);
322+
if ($fieldId === null) {
323+
Craft::$app->getProjectConfig()->defer($event, [$this, __FUNCTION__]);
324+
return;
325+
}
326+
329327
$fieldsService = Craft::$app->getFields();
330328
$contentService = Craft::$app->getContent();
331329

@@ -342,7 +340,7 @@ public function handleChangedBlockType(ConfigEvent $event)
342340
$blockTypeRecord = $this->_getBlockTypeRecord($blockTypeUid);
343341

344342
// Set the basic info on the new block type record
345-
$blockTypeRecord->fieldId = Db::idByUid('{{%fields}}', $data['field']);
343+
$blockTypeRecord->fieldId = $fieldId;
346344
$blockTypeRecord->uid = $blockTypeUid;
347345

348346
// Make sure that alterations, if any, occur in the correct context.

0 commit comments

Comments
 (0)