Maximum function nesting level reached for elements with many children on environments with XDebug

Created on 14 November 2018, over 5 years ago
Updated 10 March 2024, 4 months ago

When I run TruncateHTML on an HTML fragment that has > 256 children, I get an error "Maximum function nesting level reached" on TruncateHTML::removeProceedingNodes(). The reason is that removeProceedingNodes() goes one level of recursion deeper for every next sibling (not child, sibling!) under a parent element. Usually this is not a problem but if you have elements with many children, the call stack grows too large.

I will attach a patch that appears to solve this issue.

In order to replicate this, XDebug has to be enabled and the configuration should include the xdebug.max_nesting_level setting.

πŸ› Bug report
Status

Fixed

Version

2.1

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands sbesselsen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States ultimike Florida, USA

    Let's convert this to an issue fork against 2.1.x and see how it goes. Seems like a reasonable change (and it has an associated test!)

    -mike

  • @ultimike opened merge request.
  • Status changed to Needs review 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States ultimike Florida, USA

    I converted the patch into an MR (tests passing) - I also tweaked the test data a little.

    Needs a review or two.

    -mike

  • πŸ‡ΊπŸ‡ΈUnited States markie Albuquerque, NM

    MR makes sense but are there testing instructions for it? Does the pipeline check xdebug? What limits the test to just 3 instances of the test string?

    Not enough to say "needs work" but am curious..

  • πŸ‡ΊπŸ‡ΈUnited States ultimike Florida, USA

    My understanding of this issue is if there are bucketloads of HTML elements in the field that Smart Trim is operating on, when using xdebug, the xdebug.max_nesting_level limit can be hit.

    For manual testing, you'd need data to be Smart Trimmed that contains a bunch of HTML - so much that the xdebug.max_nesting_level it hit (as well as xdebug enabled, obviously).

    The Gitlab pipeline does not run with xdebug enabled as far as I know.

    -mike

  • Status changed to RTBC 9 months ago
  • πŸ‡ΊπŸ‡¦Ukraine ankondrat4

    Hello.

    MR was applied as expected. +1 RTBC.

  • Status changed to Fixed 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States markie Albuquerque, NM

    Merging this in. Thanks

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

Production build 0.69.0 2024