]> khamidou — GitHub mirrors - arcanist.git/commit
Make XHPAST parse-depth warning an actual warning.
authorepriestley <epriestley@phabricator.com>
Mon, 7 Mar 2011 19:21:29 +0000 (11:21 -0800)
committerepriestley <epriestley@phabricator.com>
Mon, 7 Mar 2011 19:44:11 +0000 (11:44 -0800)
commit4b303197477bca58325c1375850eff9f29e450c8
treeed8d1b6ac9be2ea9acd77672f5505b62aafe9757
parent61e16d9cc3590cb7f9eb262ca302290b6aafd8be
Make XHPAST parse-depth warning an actual warning.

Summary:
XHPAST encounters a parse-depth problem on some files because PHP
5.2 has an un-overridable parse depth limit for JSON. The text of this error
says it is a "warning" but we currently raise an error. Make it a warning
instead.

The JSON depth is 20 until PHP 5.2.3, where it becomes 128. After PHP 5.3
it defaults to 512 and is user-configurable, which will allow us to resolve
this issue in nearly all cases.

Since I made if/else express as a list in the AST, this only actually arises
in long binary chains, most commonly string concatenation, like:

  $out = 'a'.'a'.'a'.'a'...

...where each string is a variable or HTML tag and the program is constructing
a complicated document.

At some point I'll add some PHP 5.3 massaging to the XHPAST decoder itself to
raise this limit to something more huge.

Test Plan:
Ran "arc lint --lintall" on a file with a very deep binary
expression tree ("1 + 1 + 1 ...") and received a warning instead of an error.

Reviewed By: aran
Reviewers: pad, aran
CC: epriestley, aran
Differential Revision: 54
src/lint/linter/xhpast/ArcanistXHPASTLinter.php