kirki: Clean kirki install causing intermittent 503 errors in wp admin
Issue description:
On 2 different servers, we get the same issue. Even without the config (just a clean plugin installation), no other plugins, default WP theme, WP 5.1. Kirki causes 503 server errors when installing new plugins, saving menus, publishing pages, etc… The problem is that it’s not crashing every time so this is something related to PHP resource usage as it is happening intermittently.
I think I’ve found the problem and I’m 99% sure it is caused by deprecated/filters.php When looking into the code, this part is obviously a duplicate, it applies some of the filters twice. When I remove it, the 503 issues doesn’t appear.
if ( false !== strpos( $kirki_deprecated_filters_iteration[1], '-' ) ) { $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) { global $kirki_deprecated_filters_iteration; $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[0]}/{$kirki_deprecated_filters_iteration[1]}", $args ); }, 99 ); }
When I print to see what kirki deprecated filters are hooked onto init, this is the list:
kirki_global_/dynamic_css kirki_global_/output/control-classnames kirki_global_/output/control-classnames kirki_global_/css/skip_hidden kirki_global_/styles kirki_global_/output/property-classnames kirki_global_/output/property-classnames kirki_global_/webfonts/skip_hidden
Version used:
3.0.38 (but maybe it applies to earlier versions too)
Using theme_mods or options?
Doesn’t matter.
The best way to reproduce it is to install the plugin on a live website which has visits and try to add some random items to menus, create a couple of draft posts or pages, install several plugins, etc…
###EDIT
Just wanted to say that my provided solution, unfortunately, doesn’t work. While it makes sense to remove the code I pointed to, it doesn’t resolve the 503 errors…
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (7 by maintainers)
@aristath We started using Kirki for our recently published WP theme. I spent a lot of time trying to isolate this problem, and as I said, it happens even without config assigned. That’s the first thing I did, removed config. So no fields/controls at all. Then I deactivated all plugins, then I switched to a default WP theme. So it went down to just a plain plugin installation of Kirki. When I deactivate Kirki, everything works fine.
As it is hard to trace 503 error I cannot see which part of the code is causing the problem. My best guess here is that it is something related to default action hooks Kirki assigns, and doing specific actions in wp admin triggers that part of code and it exceeds server resources for a moment. And, as far as I can notice, these only happen on “save” actions which are called through admin-ajax.php, such adding items to menus, or publishing pages, or uploading images, for example.