Bug description
We recently encountered a performance issue while using the entry duplication feature.
In our project—a Statamic v5.x multisite—the action to duplicate an entry in a collection of about 1,000 entries (per site) consistently resulted in a 504 Gateway Timeout.
Could this be related in some way to the recursive function that assigns a unique slug and a title to the newly duplicated entry?
protectedfunctiongenerateTitleAndSlug(Entry$entry, $attempt = 1)
{
$title = $entry->value('title');
$slug = $entry->slug();
$suffix = ' (' . __('Duplicated') . ')';
if ($attempt == 1) {
$title = $title . $suffix;
}
if ($attempt !== 1) {
if (! Str::contains($title, $suffix)) {
$title .= $suffix;
}
$title .= ' (' . $attempt . ')';
}
$slug .= '-' . $attempt;
// If the slug we've just built already exists, we'll try again, recursively.if ($entry->collection()->queryEntries()->where('locale', $entry->locale())->where('slug', $slug)->count()) {
[$title, $slug] = $this->generateTitleAndSlug($entry, $attempt + 1);
}
return [$title, $slug];
}Has anyone else encountered this same problem or something very similar?
Or am I missing something?
How to reproduce
- Statamic v5.x, Multisite (5 sites configured).
- A collection with a non-trivial number of entries per site (~1000+) and reasonably heavy per-entry content (Bard/Replicator fields, relationships, etc.).
- Attempt to duplicate any entry in that collection via the CP "Duplicate" action.
Logs
Environment
EnvironmentApplication Name: gri.mediaLaravel Version: 12.63.0PHP Version: 8.4.23Composer Version: 2.10.1Environment: localDebug Mode: ENABLEDURL: gri-media.testMaintenance Mode: OFFTimezone: Europe/RomeLocale: itCacheConfig: CACHEDEvents: CACHEDRoutes: CACHEDViews: CACHEDDriversBroadcasting: reverbCache: redisDatabase: sqliteLogs: stack / singleMail: smtpQueue: redisSession: fileStoragepublic/storage: NOT LINKEDLocalesInstalled: ar, az, cs, da, de, de_CH, en, es, fa, fr, hu, id, it, ja, ms, nb, nl, pl, pt, pt_BR, ru, sl, sv, tr, uk, vi, zh_CN, zh_TWLaravelLang\Actions\Plugin: 1.13.2LaravelLang\Attributes\Plugin: 2.16.4LaravelLang\HttpStatuses\Plugin: 3.13.2LaravelLang\Lang\Plugin: 15.32.0LaravelLang\MoonShine\Plugin: INCORRECTLaravelLang\StarterKits\Plugin: 1.16.0Locales Version: 2.11.0Protected: en, itPublisher Version: 16.8.0StatamicAddons: 23Sites: 5 (gri.media, Il Bernina, Il Grigione Italiano, Il Moesano, La Bregaglia)Stache Watcher: DisabledStatic Caching: DisabledVersion: 5.74.3 PROStatamic Addonsaerni/social-links: 3.3.0aryehraber/statamic-captcha: 1.17.0daun/statamic-placeholders: 3.1.1doefom/currency-fieldtype: 1.4.1dryven/faviconator: 1.3.1ecomunicare/documentation: 1.1.2ecomunicare/flash-news: 1.0.5ecomunicare/infomaniak-vod: 1.0.6ecomunicare/keystone-ats-news-feed: 1.0.4ecomunicare/news-sharing: 1.0.6ecomunicare/podcast-importer: 1.0.1ecomunicare/trash-bin: 1.5.2emplify-software/statamic-cookie-dialog: 2.0.5jacksleight/statamic-bard-mutator: 3.0.5justbetter/statamic-partytown: 0.0.2mitydigital/sitemapamic: 3.5.0statamic/collaboration: 1.0.1statamic/importer: 1.9.0statamic/seo-pro: 6.11.8stillat/meerkat: 3.3.0stillat/relationships: 2.4.0swiftmade/statamic-clear-assets: 3.4.0tfd/statamic-aida: 2.2.0
Installation
Fresh statamic/statamic site via CLI
Additional details
Statamic runs in flat file mode.
Bug description
We recently encountered a performance issue while using the entry duplication feature.
In our project—a Statamic v5.x multisite—the action to duplicate an entry in a collection of about 1,000 entries (per site) consistently resulted in a 504 Gateway Timeout.
Could this be related in some way to the recursive function that assigns a unique slug and a title to the newly duplicated entry?
Has anyone else encountered this same problem or something very similar?
Or am I missing something?
How to reproduce
Logs
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
Statamic runs in flat file mode.