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

Created on 14 November 2018, about 6 years ago
Updated 10 March 2024, 8 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 about 1 year 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 about 1 year ago
  • πŸ‡ΊπŸ‡¦Ukraine ankondrat4 Lutsk

    Hello.

    MR was applied as expected. +1 RTBC.

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

    Merging this in. Thanks

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

Production build 0.71.5 2024