Skip to content

Entry::updateChildPageUris() empty($ids) check never short-circuits → every structured-entry save rewrites URIs for the entire collection #14546

@SUXUMI

Description

@SUXUMI

Bug description

Statamic\Entries\Entry::updateChildPageUris() contains an empty-check that can never be true:

// vendor/statamic/cms/src/Entries/Entry.php (6.x:511, 5.x:482)
if (empty($ids = $page->flattenedPages()->pluck('id'))) {
    return;
} 
// vendor/statamic/eloquent-driver/src/Entries/EntryRepository.php:98
public function updateUris($collection, $ids = null)
{
    $ids = collect($ids);

    $collection->queryEntries()
        ->when($ids->isNotEmpty(), fn ($query) => $query->whereIn('id', $ids))
        ->get()
        ->each(fn ($entry) => $entry->model()->update(['uri' => $entry->uri()]));
}

With an empty $ids, $ids->isNotEmpty() is false → whereIn is skipped → every entry in the collection is loaded, each URI is recomputed (walking ancestors), and a per-entry UPDATE is issued.

Observed performance impact on a non-trivial project (44 locales, news collection with 6k+ entries): every saveQuietly() on a structured news entry spends more than 26 seconds in updateChildPageUris with a ~650 MB.

How to reproduce

  1. Laravel + Statamic v6 + statamic/eloquent-driver:"^5.0".
  2. Create a structured collection
  3. Seed entries
  4. Pick a leaf entry $leaf that has NO child pages in the structure. Confirm: $leaf->page()->flattenedPages()->count() === 0.
  5. Mutate the slug (any change that passes shouldUpdateUris()):

Environment

- Statamic version: 6.14.0 (also present on 5.x branch line 482)                                                                                                                                             
- Laravel version: 12.56.0                                                                                                                                                                                                                             
- PHP version: 8.4.19                                                                                                                                                                                                                                  
- statamic/eloquent-driver: 5.6.3 (entries driver set to eloquent; collections driver file)
- DB: MySQL 8                                                                                                                                                                                                                                          
- OS: macOS 26.4

Installation

Existing Laravel app

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions