statamic / cms

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

Telescope infinite loop issue #10782

Open ScottPenhall98 opened 2 months ago

ScottPenhall98 commented 2 months ago

Bug description

It seems that this issue is still happening: https://github.com/statamic/cms/issues/5752

My issue, if you are to create a Link field on Entry A that links to Entry B, then on Entry B make a link to Entry A, you get an exception

error_screen

I have reproduced the issue here: https://github.com/ScottPenhall98/Statamic-core-Recursive-Link-bug

I also notice some big performance issues when using Telescope

How to reproduce

if you are to create a Link field on Entry A that links to Entry B, then on Entry B make a link to Entry A

Logs

going into telescope I can see we get an infinite loop. This keeps on happening over and over, I have truncated the text:

[2024-09-10 04:59:55] local.ERROR: Maximum call stack size of 8339456 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? {"userId":1,"exception":"[object] (Error(code: 0): Maximum call stack size of 8339456 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? at /app/vendor/laravel/framework/src/Illuminate/Collections/Arr.php:20)
[stacktrace]
#0 /app/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(328): Illuminate\\Support\\Arr::accessible(Array)
#1 /app/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(666): Illuminate\\Support\\Arr::get(Array, 0, NULL)
#2 /app/vendor/laravel/framework/src/Illuminate/Routing/RouteUrlGenerator.php(204): Illuminate\\Support\\Arr::pull(Array, 0)
#3 [internal function]: Illuminate\\Routing\\RouteUrlGenerator->Illuminate\\Routing\\{closure}(Array)
#4 /app/vendor/laravel/framework/src/Illuminate/Routing/RouteUrlGenerator.php(198): preg_replace_callback('/\\\\{.*?\\\\}/', Object(Closure), 'cp/collections/...')
#5 /app/vendor/laravel/framework/src/Illuminate/Routing/RouteUrlGenerator.php(85): Illuminate\\Routing\\RouteUrlGenerator->replaceRouteParameters('cp/collections/...', Array)
#6 /app/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php(500): Illuminate\\Routing\\RouteUrlGenerator->to(Object(Illuminate\\Routing\\Route), Array, true)
#7 /app/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php(469): Illuminate\\Routing\\UrlGenerator->toRoute(Object(Illuminate\\Routing\\Route), Array, true)
#8 /app/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(811): Illuminate\\Routing\\UrlGenerator->route('statamic.cp.col...', Array, true)
#9 /app/vendor/statamic/cms/src/Statamic.php(196): route('statamic.cp.col...', Array)
#10 /app/vendor/statamic/cms/src/helpers.php(9): Statamic\\Statamic::cpRoute('collections.ent...', Array)
#11 /app/vendor/statamic/cms/src/Entries/Entry.php(333): cp_route('collections.ent...', Array)
#12 /app/vendor/statamic/cms/src/Entries/Entry.php(287): Statamic\\Entries\\Entry->cpUrl('collections.ent...')
#13 /app/vendor/statamic/cms/src/Data/AbstractAugmented.php(141): Statamic\\Entries\\Entry->editUrl()
#14 /app/vendor/statamic/cms/src/Fields/Value.php(56): Statamic\\Data\\AbstractAugmented->Statamic\\Data\\{closure}(Object(Statamic\\Fields\\Value))
#15 /app/vendor/statamic/cms/src/Data/AbstractAugmented.php(78): Statamic\\Fields\\Value->resolve()
#16 /app/vendor/statamic/cms/src/Data/AbstractAugmented.php(52): Statamic\\Data\\AbstractAugmented->get('edit_url')
#17 /app/vendor/statamic/cms/src/Fields/Value.php(56): Statamic\\Data\\AbstractAugmented->Statamic\\Data\\{closure}(Object(Statamic\\Fields\\Value))
#18 /app/vendor/statamic/cms/src/Data/AugmentedCollection.php(53): Statamic\\Fields\\Value->resolve()
#19 [internal function]: Statamic\\Data\\AugmentedCollection->Statamic\\Data\\{closure}(Object(Statamic\\Fields\\Value), 'edit_url')
#20 /app/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(600): array_map(Object(Closure), Array, Array)
#21 /app/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(777): Illuminate\\Support\\Arr::map(Array, Object(Closure))
#22 /app/vendor/statamic/cms/src/Data/AugmentedCollection.php(53): Illuminate\\Support\\Collection->map(Object(Closure))
#23 /app/vendor/statamic/cms/src/Data/HasAugmentedInstance.php(35): Statamic\\Data\\AugmentedCollection->all()
#24 /app/vendor/statamic/cms/src/Fieldtypes/Link/ArrayableLink.php(17): Statamic\\Entries\\Entry->toAugmentedArray()
#25 /app/vendor/statamic/cms/src/Data/AugmentedCollection.php(87): Statamic\\Fieldtypes\\Link\\ArrayableLink->toArray()
#26 [internal function]: Statamic\\Data\\AugmentedCollection->Statamic\\Data\\{closure}(Object(Statamic\\Fieldtypes\\Link\\ArrayableLink), 'link_field')
#27 /app/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(600): array_map(Object(Closure), Array, Array)
#28 /app/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(777): Illuminate\\Support\\Arr::map(Array, Object(Closure))
#29 /app/vendor/statamic/cms/src/Data/AugmentedCollection.php(64): Illuminate\\Support\\Collection->map(Object(Closure))
#30 /app/vendor/statamic/cms/src/Data/AugmentedCollection.php(90): Statamic\\Data\\AugmentedCollection->toArray()
#31 [internal function]: Statamic\\Data\\AugmentedCollection->Statamic\\Data\\{closure}(Array, 'link_field')
#32 /app/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(600): array_map(Object(Closure), Array, Array)
#33 /app/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(777): Illuminate\\Support\\Arr::map(Array, Object(Closure))
#34 /app/vendor/statamic/cms/src/Data/AugmentedCollection.php(64): Illuminate\\Support\\Collection->map(Object(Closure))
#35 /app/vendor/statamic/cms/src/Data/AugmentedCollection.php(90): Statamic\\Data\\AugmentedCollection->toArray()
#36 [internal function]: Statamic\\Data\\AugmentedCollection->Statamic\\Data\\{closure}(Array, 'link_field')
#37 /app/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(600): array_map(Object(Closure), Array, Array)
#38 /app/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(777): Illuminate\\Support\\Arr::map(Array, Object(Closure))
#39 /app/vendor/statamic/cms/src/Data/AugmentedCollection.php(64): Illuminate\\Support\\Collection->map(Object(Closure))
#40 /app/vendor/statamic/cms/src/Data/AugmentedCollection.php(90): Statamic\\Data\\AugmentedCollection->toArray()
#41 [internal function]: Statamic\\Data\\AugmentedCollection->Statamic\\Data\\{closure}(Array, 'link_field')
#42 /app/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(600): array_map(Object(Closure), Array, Array)
#43 /app/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(777): Illuminate\\Support\\Arr::map(Array, Object(Closure))
#44 /app/vendor/statamic/cms/src/Data/AugmentedCollection.php(64): Illuminate\\Support\\Collection->map(Object(Closure))
#45 /app/vendor/statamic/cms/src/Data/AugmentedCollection.php(90): Statamic\\Data\\AugmentedCollection->toArray()
#46 [internal function]: Statamic\\Data\\AugmentedCollection->Statamic\\Data\\{closure}(Array, 'link_field')```

Environment

Application Name: _
Laravel Version: 10.48.9
PHP Version: 8.3.6
Composer Version: 2.2.22
Environment: local
Debug Mode: ENABLED
URL: _
Maintenance Mode: OFF

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

Drivers
Cache: file
Database: mysql
Logs: stack / single
Mail: smtp
Queue: database
Session: file

Statamic
Addons: 2
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.20.0 Solo

Statamic Addons
jacksleight/statamic-bard-texstyle: 3.2.2
statamic/eloquent-driver: 4.14.1

Statamic Eloquent Driver
Asset Containers: eloquent
Assets: eloquent
Blueprints: file
Collection Trees: eloquent
Collections: eloquent
Entries: eloquent
Forms: file
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: eloquent
Revisions: eloquent
Sites: file
Taxonomies: eloquent
Terms: eloquent
Tokens: file

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

hailwood commented 2 months ago

To note - the issue of the recursive link loop only happens if Telescope is installed.