The following error occurs when saving the Rendered HTML output field:
Fatal error: Nesting level too deep - recursive dependency? in /web/modules/contrib/search_api/src/Entity/Index.php on line 1418

Steps to reproduce:
- create a search index
- add Rendered HTML output field
- edit Rendered HTML output field
- save

Tested with PHP7.

The error is caused by the statement if ($old_processors != $new_processors) in Index.php in reactToProcessorChanges().

These arrays are compared recursively (by == operator) but the array itself contains recursive data:

Drupal\search_api\Plugin\search_api\processor\AggregatedFields Object
(
    [index:protected] => Drupal\search_api\Entity\Index Object
        (
            [id:protected] => test
            [name:protected] => test
            [description:protected] => 
            [read_only:protected] => 
            [field_settings:protected] => Array
                (
                    [title] => Array
                        (
                            [label] => Title
                            [datasource_id] => entity:node
                            [property_path] => title
                            [type] => string
                        )

                    [body] => Array
                        (
                            [label] => Body
                            [datasource_id] => entity:node
                            [property_path] => body
                            [type] => text
                            [dependencies] => Array
                                (
                                    [config] => Array
                                        (
                                            [0] => field.storage.node.body
                                        )

                                )

                        )

                    [rendered_item] => Array
                        (
                            [label] => Rendered HTML output
                            [datasource_id] => 
                            [property_path] => rendered_item
                            [type] => text
                            [configuration] => Array
                                (
                                    [roles] => Array
                                        (
                                            [anonymous] => anonymous
                                        )

                                    [view_mode] => Array
                                        (
                                            [entity:node] => Array
                                                (
                                                    [article] => 
                                                    [organisation] => 
                                                    [page] => 
                                                    [project] => 
                                                    [publication] => 
                                                    [researcher] => 
                                                )

                                        )

                                )

                        )

                )

            [fieldInstances:protected] => Array
                (
                    [title] => Drupal\search_api\Item\Field Object
                        (
                            [index:protected] => Drupal\search_api\Entity\Index Object
 *RECURSION*

Comments

mpp created an issue. See original summary.

mpp’s picture

Issue summary: View changes
mpp’s picture

Issue summary: View changes
drunken monkey’s picture

Title: Error saving Rendered HTML output field » Comparison of recursive processor arrays can lead to fatal error
Status: Active » Needs review
StatusFileSize
new2.88 KB

I couldn't reproduce this problem with your suggested steps. But it looks like it might indeed occur in appropriate circumstances (whatever those are).
I think we should probably just remove that check – we already check whether anything changed afterwards, and the small performance gain (if it even exists) is not worth the risk of a fatal error (or adding code that checks this manually). I don't see any functional purpose of that line.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

This also means that the code ends up being simpler, I'm all for that!

mpp’s picture

Tested and rtbc.

  • drunken monkey committed 343774a on 8.x-1.x
    Issue #2758583 by drunken monkey, mpp: Fixed processor modification code...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Committed.
Thanks again!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.