Skip to content

Commit

Permalink
Fixed #11220
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed May 20, 2022
1 parent 8aea875 commit 2d7e0f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Fixed a bug where all eager-loaded `srcset`-style transform sizes were relative to the first eager-loaded transform, rather than the prior one. ([#11209](https://github.com/craftcms/cms/issues/11209))
- Fixed a bug where eager-loaded `srcset`-style transform sizes didn’t reference the prior eager-loaded transform’s `format`, `interlace`, `mode`, `position`, or `quality` settings. ([#11264](https://github.com/craftcms/cms/issues/11264))
- Fixed a bug where the web-based installation wizard wouldn’t show the database connection screen if a connection could be established but no database was selected. ([#11245](https://github.com/craftcms/cms/issues/11245))
- Fixed an error that could occur when applying a multi-site draft with relational fields. ([#11220](https://github.com/craftcms/cms/issues/11220))

## 3.7.42 - 2022-05-11

Expand Down
31 changes: 14 additions & 17 deletions src/fields/BaseRelationField.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
use craft\queue\jobs\LocalizeRelations;
use craft\services\Elements;
use GraphQL\Type\Definition\Type;
use yii\base\Application;
use yii\base\Event;
use yii\base\InvalidConfigException;
use yii\base\NotSupportedException;
Expand Down Expand Up @@ -778,22 +777,20 @@ public function afterElementSave(ElementInterface $element, bool $isNew)
$siteIds = ArrayHelper::getColumn(ElementHelper::supportedSitesForElement($element), 'siteId');
$siteIds = ArrayHelper::withoutValue($siteIds, $element->siteId);
if (!empty($siteIds)) {
Craft::$app->on(Application::EVENT_AFTER_REQUEST, function() use ($siteIds, $element) {
$userId = Craft::$app->getUser()->getId();
$timestamp = Db::prepareDateForDb(new \DateTime());

foreach ($siteIds as $siteId) {
Db::upsert(DbTable::CHANGEDFIELDS, [
'elementId' => $element->id,
'siteId' => $siteId,
'fieldId' => $this->id,
], [
'dateUpdated' => $timestamp,
'propagated' => $element->propagating,
'userId' => $userId,
], [], false);
}
});
$userId = Craft::$app->getUser()->getId();
$timestamp = Db::prepareDateForDb(new \DateTime());

foreach ($siteIds as $siteId) {
Db::upsert(DbTable::CHANGEDFIELDS, [
'elementId' => $element->id,
'siteId' => $siteId,
'fieldId' => $this->id,
], [
'dateUpdated' => $timestamp,
'propagated' => $element->propagating,
'userId' => $userId,
], [], false);
}
}
}
}
Expand Down

0 comments on commit 2d7e0f4

Please sign in to comment.