Skip to content

Commit

Permalink
Duplicate content from primary site if possible (#2748)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Apr 17, 2018
1 parent 72f10be commit 63e963c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Control Panel panes now have at least 48 pixels of bottom padding. ([#2744](https://github.com/craftcms/cms/issues/2744))
- Craft now intercepts 404-ing resource requests, and publishes the resources on the fly.
- The Clear Caches utility now has a “Control Panel resources” option.
- When enabling new sites for a section, the new sites’ content is now based on the primary site’s content, if the section was and still is enabled for the primary site. ([#2748](https://github.com/craftcms/cms/issues/2748))

### Fixed
- Fixed a bug where the Clear Caches utility was not deleting template caches. ([#2720](https://github.com/craftcms/cms/issues/2720))
Expand Down
8 changes: 7 additions & 1 deletion src/services/Sections.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,19 @@ public function saveSection(Section $section, bool $runValidation = true): bool
$newSiteIds = array_keys($allSiteSettings);
$persistentSiteIds = array_values(array_intersect($newSiteIds, $oldSiteIds));

// Try to make that the primary site, if it's in the list
$siteId = Craft::$app->getSites()->getPrimarySite()->id;
if (!in_array($siteId, $persistentSiteIds, false)) {
$siteId = $persistentSiteIds[0];
}

Craft::$app->getQueue()->push(new ResaveElements([
'description' => Craft::t('app', 'Resaving {section} entries', [
'section' => $section->name,
]),
'elementType' => Entry::class,
'criteria' => [
'siteId' => $persistentSiteIds[0],
'siteId' => $siteId,
'sectionId' => $section->id,
'status' => null,
'enabledForSite' => false,
Expand Down

0 comments on commit 63e963c

Please # to comment.