• Resolved Zee

    (@laserjobs)


    Getting this warning from Query Monitor and not sure if it matters.
    Warning: The all action is extremely resource intensive. Try to avoid using it. 10

    Closure on line 10 of wp-content/plugins/site-reviews/helpers.php
    wp-content/plugins/site-reviews/helpers.php:10

    10 add_filter( ‘all’, function() {
    11 $args = func_get_args();
    12 $hook = array_shift( $args );
    13 $hooks = array(
    14 ‘glsr’,
    15 ‘glsr_calculate_ratings’,
    16 ‘glsr_create_review’,
    17 ‘glsr_debug’,
    18 ‘glsr_get_option’, ‘glsr_get_options’,
    19 ‘glsr_get_review’, ‘glsr_get_reviews’,
    20 ‘glsr_log’,
    21 ‘glsr_star_rating’,
    22 );
    23 if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return;
    24 add_filter( $hook, function() use( $hook, $args ) {
    25 array_shift( $args ); // remove the fallback value
    26 return call_user_func_array( $hook, $args );
    27 });
    28 });

    • This topic was modified 5 years, 8 months ago by Zee.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    This is an informational notice only, it is shown by Query Monitor at any time it detects that the “all” filter hook is being utilised. It is not an indication that the “all” action is actually being extremely resource intensive.

    Generally, it is not advisable to use the “all” WordPress filter as it is triggered on ALL WordPress hooks. However, the only thing Site Reviews uses it for is to check if the first argument passed to the filter equals one of 9 helper function names, if so, it runs the Site Reviews helper function with the parameters provided. For this check, Site Reviews simply uses in_array and function_exists. Both of these are native PHP functions and should have no discernible impact whatsoever on your site.

    This allows you to use the helper functions that Site Reviews provides in a way that will not break your site when the Site Reviews plugin is disabled and you forgot to use a “function_exists” check when using a helper function in your theme. Please see the Site Reviews > Documentation > Functions page for more information.

    All that being said, Site Reviews v3.6.0 no longer uses the “all” hook (as it is not actually necessary). However, this is only a micro-optimisation and you will detect no difference in terms of performance.

    By the way, if you are interested in profiling the hooks that are used on your website, I suggest you check out the Debug Bar + Debug Bar Slow Actions plugins.

    Thread Starter Zee

    (@laserjobs)

    I wanted to thank you for clarifying and the suggestions for debug tools.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘The all action is extremely resource intensive’ is closed to new replies.