• Looks like a great plugin!

    Unfortunately when I install it and visit any of my pages (don’t configure any of the plugin settings), I get an error: https://i.imgur.com/6XIQfia.png

    Looks like a recursive loop among these functions:

    jr_mt_all_themes( ) …/select-theme.php:125
    wp_get_themes( ) …/functions.php:80
    get_stylesheet( ) …/theme.php:41
    get_option( ) …/theme.php:160
    apply_filters( ) …/option.php:52
    jr_mt_stylesheet( ) …/plugin.php:235
    jr_mt_theme( ) …/select-theme.php:99
    jr_mt_all_themes( ) …/select-theme.php:125

    Note, the error appears twice on each of my pages:

    Fatal error: Maximum function nesting level of ‘200’ reached, aborting! in /srv/www/assigntime.com/current/web/wp/wp-includes/cache.php on line 725
    [call stack]

    Fatal error: Maximum function nesting level of ‘200’ reached, aborting! in /srv/www/assigntime.com/current/web/wp/wp-includes/wp-db.php on line 668
    [call stack]

    As indicated in your post (http://zatzlabs.com/tweaking-xdebug-to-allow-deep-function-nesting/) I’m using Xdebug, but my limit is at 200 and since it seems to be a recursive loop, I’m not confident increasing the limit will resolve the problem. If that’s wrong, let me know.

    Fwiw, my active theme is the Sage Starter Theme, which is based on this: https://roots.io/sage/ (although the error happens no matter which theme is active).

    Any suggestions would be welcome.

    Thanks!
    Justin

    https://wordpress.org/plugins/jonradio-multiple-themes/

Viewing 6 replies - 1 through 6 (of 6 total)
  • David is official support, but my experience is that this is almost certainly an interaction with another plugin or theme. I have never seen that particular type of display before, so I am assuming that “nested” is actually recursive calls.

    If so, lines 15 and 22 both being get_stylesheet() is the proof of the problem. The Multiple Themes plugin is triggered by get_stylesheet() using the official WordPress hook.

    An educated guess would say that the other plugin or theme that is causing the issue is hooking into wp_get_themes().

    I should expand my previous statement to say:

    An educated guess would say that the other plugin or theme that is causing the issue is hooking into wp_get_themes(), and calling get_stylesheet(), either directly or indirectly (through another function).

    Thread Starter justinwi

    (@justinwi)

    Thanks Jonradio for lending a hand here, really appreciated.

    I’ve deleted all of the themes except the “Twenty *” ones and all the plugins except this one. No luck.

    I also upgraded to 4.5.3 without any luck.

    I also installed this plugin on a new server config wasn’t built via Trellis (https://roots.io/trellis/) and it worked, so obviously there’s something different about this Trellis install that’s causing the problem.

    Looking at the callstack, I don’t think any other theme/plugin is getting invoked (especially because I’ve removed all of them).

    Looks like:

    1. WP tries to configure the template constants (wp-settings.php:343)
    2. That invokes jr_mt_template() hook (select-theme.php:102)
    3. The variable $jr_mt_theme[‘template’] hasn’t been defined yet (select-theme.php:123)
    4. So the plugin asks for all the themes (select-theme.php:125)
    5. That triggers the jr_mt_stylesheet() hook (different from above) (select-theme.php:98)
    6. The variable $jr_mt_theme[‘stylesheet’] hasn’t been defined yet (select-theme.php:123)
    7. So the plugin asks for all the themes again and we get into an infinite loop (select-theme.php:125)

    Overall, it looks like the logic required to define the global variables $jr_mt_theme[‘stylesheet’] and $jr_mt_theme[‘template’] tries to reference those variables, which causes the recursion.

    I’m going to try redeploying my Trellis config and see if that magically makes it go away. If not, hopefully the above will be handy as we dive in.

    Thanks again for your time.

    Justin

    At the risk of stating what seems to me to be the obvious conclusion from what you have said: Trellis is where the conflict lies. A one minute review of the Trellis web site tells me that it includes plugins, or the equivalent of plugins.

    The first place I would look, given past experience, is Caching. Find some way to (at least, temporarily) turn off Trellis caching. This guess of mine is further supported by this message you mention in your initial post:

    Fatal error: Maximum function nesting level of ‘200’ reached, aborting! in /srv/www/assigntime.com/current/web/wp/wp-includes/cache.php on line 725
    [call stack]

    Even though cache.php is a WordPress module, it is not, to the best of my knowledge, actually used except by Plugins and such that do Caching.

    Thread Starter justinwi

    (@justinwi)

    For anyone else who runs into this issue, the root cause was having multiple theme directories registered.

    Search your code for any mention of register_theme_directory (https://codex.wordpress.org/Function_Reference/register_theme_directory) and if it’s there, you’ll likely run into this issue.

    The way I resolved it was to simple remove the extra registry from my source tree.

    Thanks for the help looking into this!
    Justin

    justinwi, i have registered here to say ‘thank you’ and write about problem and solution based on your post! And it’s will be good help for guys w/ the same problem.
    —-
    I had a problem w/ Multiple Themes plugin w/ custom self-written theme. So i want to add additional theme only for only my /blog webpage and found this good solution from jonradio.
    But after adding theme and applying plugin whole website was looping & i had error on page. Only adminpanel was accessible.
    And after 2 days I traced all wp code & found problems w/ this loop.
    Plugin successfully detected main theme but wordpress somehow didn’t.

    So thing i’ve done – just added code below to index.php file:
    define(‘WP_DEFAULT_THEME’, ‘default_theme_name’);
    And this annoying loop have gone away!

    Maybe my success story will help someone ¯\_(ツ)_/¯

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Fatal error: Maximum function nesting level of '200' reached, aborting!’ is closed to new replies.