Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoking wp i18n make-pot fails when Xdebug is enabled #80

Closed
westonruter opened this issue Aug 14, 2018 · 4 comments
Closed

Invoking wp i18n make-pot fails when Xdebug is enabled #80

westonruter opened this issue Aug 14, 2018 · 4 comments
Labels

Comments

@westonruter
Copy link

westonruter commented Aug 14, 2018

In VVV after having done xdebug_on and run:

wp i18n make-pot . languages/amp-js.pot --include="*.js"

I get an error:

PHP Fatal error:  Maximum function nesting level of '100' reached, aborting! in phar:///usr/local/bin/wp/vendor/mck89/peast/lib/Peast/Syntax/Scanner.php on line 972

If I do xdebug_off then it succeeds.

The plugin context here is AMP.

@schlessera
Copy link
Member

@westonruter This is a limitation to recursion that xdebug sets into place, regular PHP without an extension doesn't have such a limit.

This limit is normally set to 256. In your case it is 100, because you are using an older version of xdebug as well (< 2.3).

You can set this limit manually using the xdebug.max_nesting_level setting.

I don't see how we could get around this from within WP-CLI, but we might want to add this to our list of common issues.

@brenoalvs
Copy link

brenoalvs commented Jul 19, 2019

@westonruter @schlessera I was working with Docker locally so I had to change two settings to be able to run the command within my container. But the command works fine if I run it directly from my machine.

memory_limit = 512M
xdebug.max_nesting_level = 512

The settings values may be a little exorbitant, but I think they're safe for development environments.
I hope it helps someone.

@EvanHerman
Copy link

Running this on CircleCI also throws the Maximum function nesting level error.

The following will disable xdebug in a CircleCI job:

- run:
    name: Disable xdebug PHP extension
    command: sudo rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

@matzeeable
Copy link
Contributor

matzeeable commented Jan 9, 2020

I just stumbled over this thread and solved it in that way:

$ php -n -dextension=phar.so -dextension=json.so -dextension=mbstring.so $(which wp) i18n make-pot [...]

I use php bin to execute wp bin so I can pass additional parameters like -n which disables all extension (see this). With dextension I can enable all extensions needed for i18n make-pot.

This also brings a huge performance improvement, here a benchmark of my WSL Ubuntu machine:

With the previous mentioned solution of @schlessera and @brenoalvs it takes about 41.42s:

$ php -d xdebug.max_nesting_level=512 $(which wp) i18n make-pot [...]
Success: POT file successfully generated!
Done in 41.42s.

And with all extensions disabled expect required ones it takes 4.42s!!

$ php -n -dextension=phar.so -dextension=json.so -dextension=mbstring.so $(which wp) i18n make-pot [...]
Success: POT file successfully generated!
Done in 4.42s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants