statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
3.71k stars 508 forks source link

Logger cannot handle entries #10805

Closed stuartcusackie closed 2 days ago

stuartcusackie commented 3 days ago

Bug description

I opened another issue where I was having trouble with EntrySaved listeners and queues. The control panel was hanging forever and my redis jobs would not complete. It turns out that the laravel logger cannot handle Statamic entries and attempting to do so causes the site to hang forever.

I know I won't be logging entire entries on a production site but I was trying to debug something locally. It was very difficult to troubleshoot this problem so maybe it can be improved.

Thanks.

How to reproduce

Try logging an entry. It hangs forever on my local environment.

$entry = \Statamic\Facades\Entry::find('xxx-xxxx-xxx');

// All of these hang forever
Log::info('Log entry', ['entry' => $entry]);
Log::info("Log entry", ['entry' => $entry->toArray()]);
Log::info("Log entry", ['entry' => json_encode($entry->toArray()]));

Logs

No response

Environment

Environment
Application Name: My Site
Laravel Version: 11.23.5
PHP Version: 8.2.13
Composer Version: 2.5.5
Environment: local
Debug Mode: ENABLED
URL: mysite.test
Maintenance Mode: OFF
Timezone: Europe/Dublin
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: single
Mail: smtp
Queue: redis
Session: file

Livewire
Livewire: v3.5.6

Statamic
Addons: 5
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.25.0 PRO

Statamic Addons
jonassiewertsen/statamic-live-search: 2.1.1
jonassiewertsen/statamic-livewire: 3.8.0
rias/statamic-redirect: 3.7.2
spatie/statamic-responsive-images: 5.0.1
statamic/seo-pro: 6.1.2

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

duncanmcclean commented 3 days ago

Does this only happen for entries in certain collections?

If it does, can you provide the YAML file for one of the collection's blueprints?

jasonvarga commented 2 days ago

Since it has to encode it, this is sometimes expected, especially if you have recursive relations. e.g. entry a links to entry b which links to entry a.

For local debugging I'd suggest a tool like myray.app Or, log $entry->id().