Replaced asset does not relink to asset fields in entries
Bug description
When using the Replace Asset function the original asset is correctly deleted (when the option is toggled on) and the new asset is correctly uploaded, however the new asset is not relinked to asset fields in entries where the original asset was being used in accordance with the documentation "Replaced assets with the replace action will update any references to it throughout your content".
How to reproduce
- Create a new entry which has an asset field.
- Upload an image
- In the asset area replace the image with another one (of a different filename - this report is not the same as #11229 )
- The asset field in the entry is now empty since the original asset is deleted and relinking did not occur
Logs
Environment
Environment
Application Name: #############################
Laravel Version: 11.44.7
PHP Version: 8.2.27
Composer Version: 2.8.6
Environment: local
Debug Mode: ENABLED
URL: #############################
Maintenance Mode: OFF
Timezone: UTC
Locale: en
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Drivers
Broadcasting: null
Cache: redis
Database: mysql
Logs: stack / single
Mail: smtp
Queue: redis
Session: file
Statamic
Addons: 8
Sites: 12 (Global (English), Germany (German), UK (English), and 9 more)
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.53.1 PRO
Statamic Addons
edalzell/forma: 3.1.1
robole/advanced-table: 0.0.0
silentz/akismet: 5.1
statamic-rad-pack/runway: 8.3.1
statamic/eloquent-driver: 4.21.1
thoughtco/statamic-cache-tracker: 0.9.3
withcandour/aardvark-seo: 5.0.3
withcandour/statamic-markdown-table: 1.0.0-beta
Statamic Eloquent Driver
Asset Containers: file
Assets: file
Blueprints: file
Collection Trees: file
Collections: file
Entries: eloquent
Forms: file
Global Sets: file
Global Variables: file
Navigation Trees: file
Navigations: file
Revisions: file
Sites: file
Taxonomies: file
Terms: file
Tokens: file
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
Is the update_references setting in config/statamic/system.php set to true or false?
Queue: redis
Statamic processes reference updates in the queue. Can you double check your queue worker is setup properly?
update_references is set to true
In the queue I have found a failed job with the following:
Illuminate\Queue\TimeoutExceededException: Statamic\Listeners\UpdateAssetReferences has timed out. in /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Queue/TimeoutExceededException.php:15
Stack trace:
#0 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(805): Illuminate\Queue\TimeoutExceededException::forJob(Object(Illuminate\Queue\Jobs\RedisJob))
#1 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(219): Illuminate\Queue\Worker->timeoutExceededException(Object(Illuminate\Queue\Jobs\RedisJob))
#2 /home/unite/releases/20250508142531/vendor/statamic/cms/src/Fieldtypes/Replicator.php(255): Illuminate\Queue\Worker->Illuminate\Queue\{closure}(14, Array)
#3 /home/unite/releases/20250508142531/vendor/statamic/cms/src/Data/DataReferenceUpdater.php(191): Statamic\Fieldtypes\Replicator->flattenedSetsConfig()
#4 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(261): Statamic\Data\DataReferenceUpdater->Statamic\Data\{closure}(Array, 14)
#5 /home/unite/releases/20250508142531/vendor/statamic/cms/src/Data/DataReferenceUpdater.php(188): Illuminate\Support\Collection->each(Object(Closure))
#6 /home/unite/releases/20250508142531/vendor/statamic/cms/src/Data/DataReferenceUpdater.php(107): Statamic\Data\DataReferenceUpdater->updateBardChildren(Object(Statamic\Fields\Field), 'bard_content')
#7 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(261): Statamic\Data\DataReferenceUpdater->Statamic\Data\{closure}(Object(Statamic\Fields\Field), 'bard_content')
#8 /home/unite/releases/20250508142531/vendor/statamic/cms/src/Data/DataReferenceUpdater.php(103): Illuminate\Support\Collection->each(Object(Closure))
#9 /home/unite/releases/20250508142531/vendor/statamic/cms/src/Assets/AssetReferenceUpdater.php(41): Statamic\Data\DataReferenceUpdater->updateNestedFieldValues(Object(Illuminate\Support\Collection), NULL)
#10 /home/unite/releases/20250508142531/vendor/statamic/cms/src/Data/DataReferenceUpdater.php(63): Statamic\Assets\AssetReferenceUpdater->recursivelyUpdateFields(Object(Illuminate\Support\Collection))
#11 /home/unite/releases/20250508142531/vendor/statamic/cms/src/Listeners/UpdateAssetReferences.php(95): Statamic\Data\DataReferenceUpdater->updateReferences('betriebsbedarfp...', 'istock-21477114...')
#12 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(261): Statamic\Listeners\UpdateAssetReferences->Statamic\Listeners\{closure}(Object(Statamic\Eloquent\Entries\Entry), 5439)
#13 /home/unite/releases/20250508142531/vendor/statamic/cms/src/Listeners/UpdateAssetReferences.php(92): Illuminate\Support\LazyCollection->each(Object(Closure))
#14 /home/unite/releases/20250508142531/vendor/statamic/cms/src/Listeners/UpdateAssetReferences.php(58): Statamic\Listeners\UpdateAssetReferences->replaceReferences(Object(Statamic\Assets\Asset), 'betriebsbedarfp...', 'istock-21477114...')
#15 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Events/CallQueuedListener.php(114): Statamic\Listeners\UpdateAssetReferences->handleReplaced(Object(Statamic\Events\AssetReplaced))
#16 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Events\CallQueuedListener->handle(Object(Illuminate\Foundation\Application))
#17 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#18 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(95): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#19 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#20 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Container/Container.php(696): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#21 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(126): Illuminate\Container\Container->call(Array)
#22 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(Illuminate\Events\CallQueuedListener))
#23 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Events\CallQueuedListener))
#24 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(130): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#25 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(126): Illuminate\Bus\Dispatcher->dispatchNow(Object(Illuminate\Events\CallQueuedListener), false)
#26 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\Queue\CallQueuedHandler->Illuminate\Queue\{closure}(Object(Illuminate\Events\CallQueuedListener))
#27 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Events\CallQueuedListener))
#28 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(121): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#29 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(69): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware(Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Events\CallQueuedListener))
#30 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(102): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\RedisJob), Array)
#31 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(442): Illuminate\Queue\Jobs\Job->fire()
#32 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(392): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Queue\WorkerOptions))
#33 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(178): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Illuminate\Queue\WorkerOptions))
#34 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(149): Illuminate\Queue\Worker->daemon('redis', 'default', Object(Illuminate\Queue\WorkerOptions))
#35 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(132): Illuminate\Queue\Console\WorkCommand->runWorker('redis', 'default')
#36 /home/unite/releases/20250508142531/vendor/laravel/horizon/src/Console/WorkCommand.php(51): Illuminate\Queue\Console\WorkCommand->handle()
#37 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Laravel\Horizon\Console\WorkCommand->handle()
#38 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#39 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(95): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#40 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#41 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Container/Container.php(696): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#42 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Console/Command.php(213): Illuminate\Container\Container->call(Array)
#43 /home/unite/releases/20250508142531/vendor/symfony/console/Command/Command.php(279): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#44 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#45 /home/unite/releases/20250508142531/vendor/symfony/console/Application.php(1094): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#46 /home/unite/releases/20250508142531/vendor/symfony/console/Application.php(342): Symfony\Component\Console\Application->doRunCommand(Object(Laravel\Horizon\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#47 /home/unite/releases/20250508142531/vendor/symfony/console/Application.php(193): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#48 /home/unite/releases/20250508142531/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(198): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#49 /home/unite/releases/20250508142531/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#50 {main}
How do you have your queue worker configured? Can you try increasing the timeout?
The worker is functioning correctly. The job times out at both 30 and 60 seconds. Would you expect this to take longer than a minute?
Potentially. It really depends on how much content you have, and what your blueprints look like. It has to loop through all content, finding asset fields and check their values.
Would be interesting to know if it still times out if you adjust the timeout to 2 minutes.
At 2 minutes timeout the replace function only works intermittently. Around 50% of the time we still fail with a timeout and ~50% of the time it works. For reference we have ~150 entries and ~50 terms all in 12 locales on this site