• I’ve been having speed issues since updating Polylang. I was able to eliminate the issues by reverting to twentyseventeen, telling me something from my theme was conflicting.

    I have now narrowed the problem down to my custom SiteOrigin Page Builder widgets. If I remove these from the theme, page load is still not as fast as without Polylang, but it goes from 9 seconds to 2.

    I have not been able to narrow it down to any one particular widget — removing them one by one doesn’t make much difference. But removing this filter and function drops the page load time considerably:

    function csl_siteorigin_widgets($folders){
    	$folders[] = get_template_directory() . '/lib/siteorigin-widgets/';
    	return $folders;
    }
    add_filter('siteorigin_widgets_widget_folders', 'csl_siteorigin_widgets');

    Additionally, leaving these widgets in place without Polylang decreases load time significantly. So it’s something with the combination of the two.

    I don’t recall this problem until recently. It is a problem on both the frontend and the admin, and began with either the last update — Aug 16th — or possibly the one before that in July.

    Permalink format: /2017/08/sample-post/
    Static front page: Yes
    Polylang settings:
    The language is set from the directory name in pretty permalinks
    Remove /language/ in pretty permalinks
    Synchronization on, but only page type
    Languages are English (default) and Spanish (just a few pages)

    Thanks for any help or direction you can provide.

    Tim

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Tim

    (@timstl)

    I downloaded each branch from the github repository. I wanted to share my results in case it sparks any ideas:

    1.9.x – The fastest.
    2.0.x – Similar, but slightly slower.
    2.1.x – This is where the problems seem to begin.
    master – Comparable to 2.1, maybe slightly slower.

    Thread Starter Tim

    (@timstl)

    I’m still seeing this problem in 2.2.1 and have some additional information.

    While the problem is related to SiteOrigin Widgets in my case, I’m wondering if there is possibly a larger problem with sidebar widgets. Here is my minimum setup that I used to reproduce:

    – Plugins enabled: Polylang, PageBuilder by SiteOrigin, SiteOrigin Widgets Bundled
    – My theme loads 13 custom SiteOrigin widgets via the code in the original post.

    With this setup, Query Monitor shows a load time (on average) of 12 seconds, but does not show any slow queries. Deactivating Polylang or SiteOrigin drops the load time to around 1. Here is where the problem gets more specific:

    – I narrowed the problem down to just 2 of my custom widgets, and removing all code from them does not fix the problem. Just the existence of these 2 widget files – with no code in them – slows the site. But removing the widget folders entirely drops the load time significantly.

    The thing that these two widgets have in common is that they are the two custom SiteOrigin widgets used heavily throughout the site’s sidebars. I believe there’s only 1 other custom widget that is used once, but these are used frequently. The other widgets are used within page content. I do use other plugin widgets (when activated) and native WP widgets as well. Turning those on and off does not seem to change performance.

    One other important piece of information — I have built a lot of custom sidebars using the Custom Sidebars by WPMU Dev. It is not enabled during these tests, so only my themes three sidebars exist, but I am not sure if that changes how data is stored in the database. The sidebars_widget option in wp_options is rather large:

    a:77:{s:27:"primary-sidebar-widget-area";a:6:{i:0;s:8:"search-2";i:1;s:14:"recent-posts-2";i:2;s:17:"recent-comments-2";i:3;s:10:"archives-2";i:4;s:12:"categories-2";i:5;s:6:"meta-2";}s:19:"wp_inactive_widgets";a:4:{i:0;s:10:"nav_menu-7";i:1;s:29:"XXXXXXXXX-contactus-widget-12";i:2;s:31:"tribe-events-adv-list-widget-20";i:3;s:21:"tribe-mini-calendar-2";}s:5:"cs-21";a:1:{i:0;s:11:"nav_menu-21";}s:5:"cs-20";a:2:{i:0;s:11:"nav_menu-22";i:1;s:24:"bt-gravity-form-widget-3";}s:5:"cs-22";a:2:{i:0;s:11:"nav_menu-23";i:1;s:25:"bt-gravity-form-widget-51";}s:4:"cs-2";a:5:{i:0;s:10:"nav_menu-3";i:1;s:30:"tribe-events-adv-list-widget-7";i:2;s:7:"text-30";i:3;s:28:"XXXXXXXXX-contactus-widget-2";i:4;s:25:"bt-gravity-form-widget-15";}s:5:"cs-63";a:6:{i:0;s:10:"polylang-2";i:1;s:11:"nav_menu-53";i:2;s:31:"tribe-events-adv-list-widget-48";i:3;s:29:"XXXXXXXXX-contactus-widget-45";i:4;s:7:"text-24";i:5;s:25:"bt-gravity-form-widget-57";}s:5:"cs-65";a:5:{i:0;s:11:"nav_menu-59";i:1;s:31:"tribe-events-adv-list-widget-55";i:2;s:7:"text-36";i:3;s:29:"XXXXXXXXX-contactus-widget-47";i:4;s:25:"bt-gravity-form-widget-68";}s:5:"cs-44";a:4:{i:0;s:11:"nav_menu-39";i:1;s:31:"tribe-events-adv-list-widget-31";i:2;s:28:"XXXXXXXXX-contactus-widget-3";i:3;s:25:"bt-gravity-form-widget-16";}s:5:"cs-27";a:5:{i:0;s:11:"nav_menu-27";i:1;s:31:"tribe-events-adv-list-widget-40";i:2;s:31:"tribe-events-adv-list-widget-63";i:3;s:28:"XXXXXXXXX-contactus-widget-4";i:4;s:25:"bt-gravity-form-widget-23";}s:5:"cs-28";a:8:{i:0;s:10:"polylang-5";i:1;s:11:"nav_menu-26";i:2;s:31:"tribe-events-adv-list-widget-41";i:3;s:7:"text-17";i:4;s:28:"XXXXXXXXX-contactus-widget-5";i:5;s:29:"XXXXXXXXX-contactus-widget-46";i:6;s:7:"text-27";i:7;s:25:"bt-gravity-form-widget-24";}s:5:"cs-72";a:3:{i:0;s:31:"tribe-events-adv-list-widget-65";i:1;s:7:"text-40";i:2;s:29:"XXXXXXXXX-contactus-widget-54";}s:5:"cs-29";a:6:{i:0;s:10:"polylang-3";i:1;s:11:"nav_menu-28";i:2;s:31:"tribe-events-adv-list-widget-42";i:3;s:28:"XXXXXXXXX-contactus-widget-6";i:4;s:7:"text-25";i:5;s:25:"bt-gravity-form-widget-25";}s:5:"cs-43";a:5:{i:0;s:11:"nav_menu-38";i:1;s:31:"tribe-events-adv-list-widget-30";i:2;s:28:"XXXXXXXXX-contactus-widget-7";i:3;s:25:"bt-gravity-form-widget-14";i:4;s:25:"bt-gravity-form-widget-56";}s:5:"cs-40";a:6:{i:0;s:10:"polylang-4";i:1;s:31:"tribe-events-adv-list-widget-28";i:2;s:28:"XXXXXXXXX-contactus-widget-8";i:3;s:7:"text-26";i:4;s:25:"bt-gravity-form-widget-50";i:5;s:25:"bt-gravity-form-widget-75";}s:5:"cs-17";a:2:{i:0;s:11:"nav_menu-18";i:1;s:25:"bt-gravity-form-widget-36";}s:5:"cs-10";a:4:{i:0;s:11:"nav_menu-10";i:1;s:31:"tribe-events-adv-list-widget-12";i:2;s:28:"XXXXXXXXX-contactus-widget-9";i:3;s:25:"bt-gravity-form-widget-37";}s:5:"cs-66";a:3:{i:0;s:11:"nav_menu-60";i:1;s:31:"tribe-events-adv-list-widget-56";i:2;s:25:"bt-gravity-form-widget-69";}s:5:"cs-11";a:3:{i:0;s:11:"nav_menu-12";i:1;s:31:"tribe-events-adv-list-widget-13";i:2;s:25:"bt-gravity-form-widget-38";}s:4:"cs-6";a:3:{i:0;s:10:"nav_menu-5";i:1;s:29:"XXXXXXXXX-contactus-widget-10";i:2;s:25:"bt-gravity-form-widget-39";}s:4:"cs-9";a:4:{i:0;s:10:"nav_menu-9";i:1;s:31:"tribe-events-adv-list-widget-11";i:2;s:29:"XXXXXXXXX-contactus-widget-11";i:3;s:25:"bt-gravity-form-widget-40";}s:4:"cs-8";a:3:{i:0;s:10:"nav_menu-8";i:1;s:29:"XXXXXXXXX-contactus-widget-13";i:2;s:25:"bt-gravity-form-widget-41";}s:5:"cs-14";a:3:{i:0;s:11:"nav_menu-15";i:1;s:29:"XXXXXXXXX-contactus-widget-14";i:2;s:25:"bt-gravity-form-widget-42";}s:4:"cs-1";a:5:{i:0;s:10:"nav_menu-2";i:1;s:31:"tribe-events-adv-list-widget-25";i:2;s:29:"XXXXXXXXX-contactus-widget-15";i:3;s:6:"text-4";i:4;s:25:"bt-gravity-form-widget-43";}s:5:"cs-71";a:4:{i:0;s:11:"nav_menu-65";i:1;s:31:"tribe-events-adv-list-widget-61";i:2;s:29:"XXXXXXXXX-contactus-widget-48";i:3;s:25:"bt-gravity-form-widget-74";}s:5:"cs-18";a:4:{i:0;s:11:"nav_menu-19";i:1;s:31:"tribe-events-adv-list-widget-44";i:2;s:29:"XXXXXXXXX-contactus-widget-17";i:3;s:25:"bt-gravity-form-widget-45";}s:5:"cs-19";a:4:{i:0;s:11:"nav_menu-20";i:1;s:29:"XXXXXXXXX-contactus-widget-16";i:2;s:31:"tribe-events-adv-list-widget-43";i:3;s:25:"bt-gravity-form-widget-44";}s:5:"cs-13";a:3:{i:0;s:11:"nav_menu-14";i:1;s:29:"XXXXXXXXX-contactus-widget-18";i:2;s:25:"bt-gravity-form-widget-46";}s:5:"cs-12";a:4:{i:0;s:11:"nav_menu-13";i:1;s:31:"tribe-events-adv-list-widget-14";i:2;s:29:"XXXXXXXXX-contactus-widget-19";i:3;s:25:"bt-gravity-form-widget-47";}s:5:"cs-15";a:3:{i:0;s:11:"nav_menu-16";i:1;s:29:"XXXXXXXXX-contactus-widget-20";i:2;s:25:"bt-gravity-form-widget-48";}s:5:"cs-16";a:3:{i:0;s:11:"nav_menu-17";i:1;s:29:"XXXXXXXXX-contactus-widget-21";i:2;s:25:"bt-gravity-form-widget-49";}s:5:"cs-26";a:6:{i:0;s:10:"polylang-6";i:1;s:11:"nav_menu-45";i:2;s:31:"tribe-events-adv-list-widget-18";i:3;s:7:"text-39";i:4;s:29:"XXXXXXXXX-contactus-widget-51";i:5;s:29:"XXXXXXXXX-contactus-widget-22";}s:5:"cs-46";a:3:{i:0;s:11:"nav_menu-46";i:1;s:31:"tribe-events-adv-list-widget-32";i:2;s:29:"XXXXXXXXX-contactus-widget-23";}s:5:"cs-47";a:3:{i:0;s:11:"nav_menu-47";i:1;s:31:"tribe-events-adv-list-widget-33";i:2;s:29:"XXXXXXXXX-contactus-widget-24";}s:5:"cs-48";a:4:{i:0;s:11:"nav_menu-48";i:1;s:31:"tribe-events-adv-list-widget-34";i:2;s:7:"text-15";i:3;s:29:"XXXXXXXXX-contactus-widget-25";}s:5:"cs-67";a:2:{i:0;s:11:"nav_menu-61";i:1;s:31:"tribe-events-adv-list-widget-57";}s:5:"cs-49";a:3:{i:0;s:11:"nav_menu-49";i:1;s:31:"tribe-events-adv-list-widget-35";i:2;s:29:"XXXXXXXXX-contactus-widget-26";}s:5:"cs-38";a:2:{i:0;s:11:"nav_menu-35";i:1;s:29:"XXXXXXXXX-contactus-widget-27";}s:5:"cs-39";a:2:{i:0;s:11:"nav_menu-36";i:1;s:31:"tribe-events-adv-list-widget-49";}s:5:"cs-41";a:1:{i:0;s:6:"text-5";}s:5:"cs-52";a:4:{i:0;s:11:"nav_menu-44";i:1;s:31:"tribe-events-adv-list-widget-37";i:2;s:29:"XXXXXXXXX-contactus-widget-42";i:3;s:25:"bt-gravity-form-widget-17";}s:5:"cs-61";a:0:{}s:5:"cs-58";a:4:{i:0;s:10:"nav_menu-6";i:1;s:31:"tribe-events-adv-list-widget-53";i:2;s:7:"text-34";i:3;s:25:"bt-gravity-form-widget-64";}s:5:"cs-42";a:6:{i:0;s:11:"nav_menu-37";i:1;s:31:"tribe-events-adv-list-widget-29";i:2;s:6:"text-7";i:3;s:29:"XXXXXXXXX-contactus-widget-28";i:4;s:25:"bt-gravity-form-widget-18";i:5;s:24:"bt-gravity-form-widget-9";}s:5:"cs-64";a:6:{i:0;s:11:"nav_menu-58";i:1;s:31:"tribe-events-adv-list-widget-54";i:2;s:7:"text-35";i:3;s:29:"XXXXXXXXX-contactus-widget-53";i:4;s:29:"XXXXXXXXX-contactus-widget-52";i:5;s:25:"bt-gravity-form-widget-66";}s:5:"cs-62";a:3:{i:0;s:11:"nav_menu-52";i:1;s:31:"tribe-events-adv-list-widget-47";i:2;s:29:"XXXXXXXXX-contactus-widget-43";}s:5:"cs-70";a:0:{}s:5:"cs-69";a:4:{i:0;s:11:"nav_menu-63";i:1;s:31:"tribe-events-adv-list-widget-59";i:2;s:7:"text-37";i:3;s:25:"bt-gravity-form-widget-72";}s:5:"cs-59";a:4:{i:0;s:11:"nav_menu-64";i:1;s:31:"tribe-events-adv-list-widget-60";i:2;s:7:"text-38";i:3;s:25:"bt-gravity-form-widget-73";}s:4:"cs-5";a:4:{i:0;s:10:"nav_menu-4";i:1;s:30:"tribe-events-adv-list-widget-6";i:2;s:7:"text-28";i:3;s:25:"bt-gravity-form-widget-19";}s:5:"cs-23";a:5:{i:0;s:31:"tribe-events-adv-list-widget-15";i:1;s:29:"XXXXXXXXX-contactus-widget-29";i:2;s:29:"XXXXXXXXX-contactus-widget-30";i:3;s:29:"XXXXXXXXX-contactus-widget-55";i:4;s:25:"bt-gravity-form-widget-20";}s:5:"cs-55";a:4:{i:0;s:11:"nav_menu-54";i:1;s:31:"tribe-events-adv-list-widget-50";i:2;s:7:"text-33";i:3;s:25:"bt-gravity-form-widget-58";}s:5:"cs-57";a:4:{i:0;s:11:"nav_menu-56";i:1;s:31:"tribe-events-adv-list-widget-52";i:2;s:7:"text-32";i:3;s:25:"bt-gravity-form-widget-62";}s:5:"cs-24";a:5:{i:0;s:11:"nav_menu-24";i:1;s:31:"tribe-events-adv-list-widget-16";i:2;s:7:"text-29";i:3;s:29:"XXXXXXXXX-contactus-widget-31";i:4;s:25:"bt-gravity-form-widget-21";}s:5:"cs-56";a:4:{i:0;s:11:"nav_menu-55";i:1;s:31:"tribe-events-adv-list-widget-51";i:2;s:7:"text-31";i:3;s:25:"bt-gravity-form-widget-60";}s:5:"cs-53";a:6:{i:0;s:11:"nav_menu-50";i:1;s:31:"tribe-events-adv-list-widget-62";i:2;s:31:"tribe-events-adv-list-widget-45";i:3;s:29:"XXXXXXXXX-contactus-widget-49";i:4;s:7:"text-22";i:5;s:25:"bt-gravity-form-widget-52";}s:5:"cs-54";a:4:{i:0;s:11:"nav_menu-51";i:1;s:31:"tribe-events-adv-list-widget-46";i:2;s:7:"text-23";i:3;s:25:"bt-gravity-form-widget-54";}s:5:"cs-25";a:3:{i:0;s:11:"nav_menu-25";i:1;s:31:"tribe-events-adv-list-widget-17";i:2;s:25:"bt-gravity-form-widget-22";}s:5:"cs-36";a:2:{i:0;s:11:"nav_menu-34";i:1;s:25:"bt-gravity-form-widget-26";}s:5:"cs-33";a:4:{i:0;s:11:"nav_menu-32";i:1;s:31:"tribe-events-adv-list-widget-21";i:2;s:29:"XXXXXXXXX-contactus-widget-33";i:3;s:25:"bt-gravity-form-widget-27";}s:5:"cs-35";a:5:{i:0;s:11:"nav_menu-33";i:1;s:31:"tribe-events-adv-list-widget-24";i:2;s:27:"bt-cycle-slideshow-widget-2";i:3;s:29:"XXXXXXXXX-contactus-widget-34";i:4;s:25:"bt-gravity-form-widget-28";}s:4:"cs-3";a:3:{i:0;s:6:"text-2";i:1;s:31:"tribe-events-adv-list-widget-22";i:2;s:25:"bt-gravity-form-widget-29";}s:5:"cs-34";a:3:{i:0;s:7:"text-21";i:1;s:31:"tribe-events-adv-list-widget-23";i:2;s:25:"bt-gravity-form-widget-30";}s:5:"cs-45";a:3:{i:0;s:11:"nav_menu-40";i:1;s:29:"XXXXXXXXX-contactus-widget-35";i:2;s:25:"bt-gravity-form-widget-31";}s:5:"cs-30";a:3:{i:0;s:11:"nav_menu-29";i:1;s:29:"XXXXXXXXX-contactus-widget-36";i:2;s:25:"bt-gravity-form-widget-32";}s:5:"cs-31";a:3:{i:0;s:11:"nav_menu-30";i:1;s:29:"XXXXXXXXX-contactus-widget-37";i:2;s:25:"bt-gravity-form-widget-33";}s:5:"cs-32";a:3:{i:0;s:11:"nav_menu-31";i:1;s:29:"XXXXXXXXX-contactus-widget-38";i:2;s:25:"bt-gravity-form-widget-34";}s:5:"cs-51";a:1:{i:0;s:24:"bt-gravity-form-widget-7";}s:5:"cs-37";a:4:{i:0;s:11:"nav_menu-42";i:1;s:29:"XXXXXXXXX-contactus-widget-39";i:2;s:24:"bt-gravity-form-widget-5";i:3;s:13:"media_image-3";}s:5:"cs-50";a:4:{i:0;s:11:"nav_menu-43";i:1;s:29:"XXXXXXXXX-contactus-widget-41";i:2;s:24:"bt-gravity-form-widget-6";i:3;s:13:"media_image-4";}s:5:"cs-68";a:4:{i:0;s:11:"nav_menu-62";i:1;s:31:"tribe-events-adv-list-widget-58";i:2;s:25:"bt-gravity-form-widget-71";i:3;s:13:"media_image-5";}s:4:"cs-4";a:4:{i:0;s:11:"nav_menu-41";i:1;s:31:"tribe-events-adv-list-widget-26";i:2;s:24:"bt-gravity-form-widget-4";i:3;s:13:"media_image-2";}s:24:"blog-sidebar-widget-area";a:4:{i:0;s:30:"tribe-events-adv-list-widget-4";i:1;s:24:"bt-gravity-form-widget-2";i:2;s:27:"XXXXXXXXX-followus-widget-2";i:3;s:29:"XXXXXXXXX-contactus-widget-40";}s:24:"page-sidebar-widget-area";a:0:{}s:25:"store-sidebar-widget-area";a:1:{i:0;s:32:"woocommerce_product_categories-2";}s:9:"mega-menu";a:2:{i:0;s:11:"sow-image-2";i:1;s:11:"sow-image-3";}s:13:"array_version";i:3;}

    Additionally, I tried to use Theme & Plugin Profiler, but can only get it to display 1 function (include_once).

    Function Name Execution calls Total execution time Execution time per call
    include_once 1 0.0000586510 0.0000586510
    Total 1 0.0000586510 0.0000586510

    Dev environment is PHP v7.0.18, but this happens on two other servers running different minor versions of PHP 7.0.

    Thread Starter Tim

    (@timstl)

    Alright, I’ve narrowed the performance problems I’m seeing down to a single line of code in frontend-filters.php:

    $widget_settings = $wp_registered_widgets[ $widget ]['callback'][0]->get_settings();

    Current tests are 14s load time with that line of code, 1s without.

    Commenting this out fixes everything, but obviously that is not a real solution. I’m assuming this is there for a reason.

    Having said that, my widgets seem to work fine without the entire sidebar_widgets function — which appears to be how 1.9 worked as well. As a temporary solution, I’ve removed:

    add_filter( 'sidebars_widgets', array( $this, 'sidebars_widgets' ) );

    My guess is everything works fine because I don’t have any sidebars that are made up entirely of individual languages.

    • This reply was modified 7 years, 2 months ago by Tim.
    Thread Starter Tim

    (@timstl)

    Here is a ‘safe’ way to remove this filter without modifying the plugin, if anyone else runs into this problem. My understanding is this is needed if you’re using is_active_sidebar() to check if a sidebar has widgets (Reference: https://github.com/polylang/polylang/issues/54), so you may run into unexpected problems.

    You can add this code to your theme’s functions.php:

    if ( ! function_exists( 'remove_anonymous_object_filter' ) )
    {
    	/**
    	 https://wordpress.stackexchange.com/questions/57079/how-to-remove-a-filter-that-is-an-anonymous-object
    	 
    	 * Remove an anonymous object filter.
    	 *
    	 * @param	string $tag	  Hook name.
    	 * @param	string $class  Class name
    	 * @param	string $method Method name
    	 * @return void
    	 */
    	function remove_anonymous_object_filter( $tag, $class, $method )
    	{
    		$filters = $GLOBALS['wp_filter'][ $tag ];
    
    		if ( empty ( $filters ) )
    		{
    			return;
    		}
    
    		foreach ( $filters as $priority => $filter )
    		{
    			foreach ( $filter as $identifier => $function )
    			{
    				if ( is_array( $function)
    					and is_a( $function['function'][0], $class )
    					and $method === $function['function'][1]
    				)
    				{
    					remove_filter(
    						$tag,
    						array ( $function['function'][0], $method ),
    						$priority
    					);
    				}
    			}
    		}
    	}
    }
    
    function remove_sidebar_widgets_polylang_filter() {
    	if( class_exists('PLL_Frontend_Filters' ) ){
    		 remove_anonymous_object_filter(
    			 'sidebars_widgets',
    			 'PLL_Frontend_Filters',
    			 'sidebars_widgets'
    		 );
    	}
    }
    add_action( 'init','remove_sidebar_widgets_polylang_filter', 100 );
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘SiteOrigin Page Builder + Polylang 2.2 speed issues’ is closed to new replies.