Skip to content

Commit

Permalink
Merge pull request #1381 from craftcms/bugfix/1208-element-enabled-at…
Browse files Browse the repository at this point in the history
…tribute

order of events for setting enabled & enabledForSite
  • Loading branch information
angrybrad authored Nov 25, 2023
2 parents bd2e6fc + a728231 commit 8ac5f92
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/services/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,6 @@ public function processFeed($step, $feed, &$processedElementIds, $feedData = nul
}
}

// Set the attributes for the element
$element->setAttributes($attributeData, false);

$contentData = [];
if (isset($attributeData['enabled'])) {
// Set the site-specific status as well, but retain all other site statuses
Expand All @@ -390,8 +387,13 @@ public function processFeed($step, $feed, &$processedElementIds, $feedData = nul
$element->setEnabledForSite($enabledForSite);
$contentData['enabled'] = $element->enabled;
$contentData['enabledForSite'] = $element->getEnabledForSite($element->siteId);

unset($attributeData['enabled']);
}

// Set the attributes for the element
$element->setAttributes($attributeData, false);

// Then, do the same for custom fields. Again, this should be done after populating the element attributes
foreach ($feed['fieldMapping'] as $fieldHandle => $fieldInfo) {
if (Hash::get($fieldInfo, 'field')) {
Expand Down

0 comments on commit 8ac5f92

Please sign in to comment.