Req #71571 [NEW]: XSLT processor should provide option to change maxDepth
From: sam dot marshall at open dot ac dot uk
Operating system:
PHP version: 7.0.3
Package: XSLT related
Bug Type: Feature/Change Request
Bug description:XSLT processor should provide option to change maxDepth
Description:
------------
The libxslt XSLT processor has a recursion depth limit, which appears to
be different in different versions. (I briefly looked at the libxslt
source and couldn't find this change so it might depend on the operating
system and/or PHP version, or specific OS configuration.)
The provided test script demonstrates the recursion limit in practice;
the script will print out lots of numbers before ending with an error,
and the recursion limit is the last number + 1. Here are some examples
from three different systems:
PHP 5.4.36 RHEL 5, libxslt 1.1.17: limit is 12,500
PHP 5.4.40 RHEL 7, libxslt 1.1.28: limit is 3,000
PHP 7.0.3 Mac, libxslt 1.1.28: limit is 3,000
When you hit the recursion limit, you see the following information in
the PHP warnings that appear:
Warning: XSLTProcessor::transformToDoc(): runtime error: [...]
Warning: XSLTProcessor::transformToDoc(): xsltApplyXSLTTemplate: A
potential infinite template recursion was detected.
You can adjust xsltMaxDepth (--maxdepth) in order to raise the maximum
number of nested template calls and variables/params (currently set to
3000). in [...]
This is a helpful message and if using the command-line xsltproc or the
C library, I believe it's possible to adjust that maximum number exactly
as it says. However, there is currently no way to change the maxdepth
parameter from PHP.
So the change request: It would be nice if there were a php.ini
parameter, or a way to set this on the XSLTProcessor instance, or
something similar, so that this value could be increased.
For background: when using pure XSLT it is often necessary to create
heavily recursive code, so the 3,000 limit is actually not completely
unreasonable (although it does probably indicate that your code could do
with a rewrite - in the case where I actually experienced this problem,
I was able to resolve it by changing the XSLT, but it would be good to
have the option of changing the parameter).
Test script:
---------------
http://pastebin.com/B0rRaRH2
--
Edit bug report at https://bugs.php.net/bug.php?id=71571&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71571&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71571&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71571&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71571&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71571&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71571&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71571&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71571&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71571&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71571&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71571&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71571&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71571&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71571&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71571&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71571&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71571&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71571&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71571&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71571&r=mysqlcfg
Thread (4 messages)
- sam dot marshall at open dot ac dot uk