cms icon indicating copy to clipboard operation
cms copied to clipboard

The `Statamic::isWorker()` check may need to also apply to console commands

Open simonworkhouse opened this issue 7 months ago • 0 comments

Bug description

The entry stache is prone to getting out of sync when console commands are running at the same time as someone is modifying entries in the admin panel.

We have experienced a number of different issues from this, such as:

  • Collection tree with duplicate IDs causing 500s on front-end.
  • Empty/junk entries appear after they have been deleted in the admin panel.
  • Others I cannot think of right now... but nothing fun.

Something that does address this issue is updating Statamic::isWorker() to simply return App::runningInConsole(), although I am not currently sure of the performance implications of doing so.

How to reproduce

See the example test entry_stache_maintains_sync_with_cli_commands here: https://github.com/statamic/cms/blob/621180a2be6cc109ed45c8545d5710525678fe64/tests/Data/Entries/EntryTest.php#L2578-L2639

When uncommenting the following line, you'll see that the test functions correctly.

\Illuminate\Support\Facades\Request::swap(new \Tests\Fakes\FakeArtisanRequest('queue:work'));

Logs

No response

Environment

Environment
Application Name: Testing Things
Laravel Version: 10.48.17
PHP Version: 8.2.18
Composer Version: 2.7.1
Environment: local
Debug Mode: ENABLED
URL: testing-things.localhost
Maintenance Mode: OFF

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

simonworkhouse avatar Jul 26 '24 11:07 simonworkhouse