• Resolved ahillmortons

    (@ahillmortons)


    Hi,

    I have debug turned on and I keep getting this error come up when I go to the bbp Style Pack settings, do you know what it means and/or what might be causing it?

    Only variables should be passed by reference in /var/web/site/public_html/wp-content/object-cache.php on line 315
    [28-Sep-2023 15:48:21 UTC] PHP Notice: wp_cache_flush() used, this is broadly not recommended. Called in /var/web/site/public_html/wp-content/plugins/bbp-style-pack/includes/functions.php line 3529 in /var/web/site/public_html/wp-content/object-cache.php on line 320

    I am hosted with WPMU Dev and using a multisite.

    Many Thanks,

    Andy

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thank you for reporting this!

    Good news is that it’s a notice and not a warning/error/critical error. You can safely keep using Style Pack as-is without any issue.

    wp_cache_flush() is a built-in WordPress function to clear cache, and gets called anytime cache is cleared. Style Pack clears cache every time changes are made that affect visual aspects of the site. It’s normal functionality, but I wouldn’t want my life filling up with notices about it either.

    I will look into why you’re getting the notice and see if there’s a way to make it play nice with your hosting.

    Thread Starter ahillmortons

    (@ahillmortons)

    Hi @codejp3

    Thanks for your prompt reply.

    I was speaking with WPMU support who flagged the error with me and made this comment:

    I was checking the PHP logs as well and I see this:
    [28-Sep-2023 15:42:38 UTC] PHP Notice: wp_cache_flush() used,
    this is broadly not recommended. Called in /var/web/site/public_html/
    wp-content/plugins/bbp-style-pack/includes/functions.php line 3529 in
    /var/web/site/public_html/wp-content/object-cache.php on line 320
    Meaning that the bbp-style-pack is clearing the Object Cache
    constantly, meaning that it will slow down the query and DB. Can you
    try to disable that plugin temporarily to check if it will load faster?

    Which is why I got in touch, if you think it isn’t causing any issues then I’ll not worry about it, I just wanted to check.

    Thanks,

    Andy

    Plugin Author Robin W

    (@robin-w)

    the clear cache only fires on changes to settings and updates of the style pack plugin so it only clears cache then. No criticism of WPMU who quiet rightly don’t have time to look through many dozens of files to see when it runs.

    Yeah, WPMU isn’t to blame. That notice could absolutely be helpful with diagnosing bad site performance or misbehaving plugins.

    Style Pack clears cache intentionally, every time you change settings that affect the site front-end visually.

    Once you have Style Pack setup according to your preferences and no longer changing settings, it will NOT clear cache.

    If you look at the support topics in Style Pack for 2022 and before, you’ll find tons of “it’s not working” topics with the magic solution was to clear browser cache and/or site cache. Since implementing auto cache clearing, I don’t think there’s been a single cache-related “it’s not working” topic.

    Thread Starter ahillmortons

    (@ahillmortons)

    Thanks for your replies.

    I did say to WPMU I was sure it wasn’t bbpSP, but they kept mentioning it and asked me to reach out.

    I turned off my FSE theme and bbpSP also to show them an issue persisted with a long delay when a new topic was being posted and they have agreed bbpSP isn’t causing the issue now.

    Thanks for your help and time. Great plugin by the way.

    Many Thanks,

    Andy

    Thread Starter ahillmortons

    (@ahillmortons)

    Hi Both,

    Not exactly the same issue, but we have gone live with the site and had been using the Latest Activity Widget on a sidebar. The site was running low and the process was being flagged as slow in the logs.

    I’ve removed the widget from the sidebar for now but just wondered if you had any ideas why this might be?

    Here’s the error:

    [19-Oct-2023 13:31:22] script_filename = /var/web/site/public_html/index.php ; mysqli_query() /var/web/site/public_html/wp-includes/class-wpdb.php:2459 ; _do_query() /var/web/site/public_html/wp-includes/class-wpdb.php:2346 ; query() /var/web/site/public_html/wp-includes/class-wpdb.php:3088 ; get_col() /var/web/site/public_html/wp-includes/class-wp-query.php:3312 ; get_posts() /var/web/site/public_html/wp-includes/class-wp-query.php:3800 ; query() /var/web/site/public_html/wp-includes/class-wp-query.php:3932 ; __construct() /var/web/site/public_html/wp-content/plugins/bbp-style-pack/blocks/bsp-latest-activity-widget.php:127

    It’s quite a large database with the posts, postmeta, users and usermeta table tables being large with 48k users and 620k replies.

    Many Thanks,

    Andy

    Plugin Author Robin W

    (@robin-w)

    what are you sorting by freshness, popular, newness? and does this change if you sort by a different option?

    Thread Starter ahillmortons

    (@ahillmortons)

    Hi Robin,

    I had 2 active.

    The first was:
    Newest Topics
    Max number:
    Show Freshness: Off
    Shorten Freshness: Off
    Show Topic Author: Off
    Hide Avatar: Off
    Show Forum: Off
    Show Parent Forum: Off
    Show Count Reply: Off

    The second one below it was the same settings but for ‘Topics with recent Replies’

    I’ll try re-adding just one and test in different configurations.

    Many Thanks,

    Andy

    Thread Starter ahillmortons

    (@ahillmortons)

    Hi Robin,

    I tried adding a single feed back in with 5 posts (rather than the 10 is was on before that I seem to have missed out).

    The CPU of the server maxed out right away and the same error came up in the slow logs:

    [19-Oct-2023 16:51:08] script_filename = /var/web/site/public_html/index.php ; mysqli_query() /var/web/site/public_html/wp-includes/class-wpdb.php:2459 ; _do_query() /var/web/site/public_html/wp-includes/class-wpdb.php:2346 ; query() /var/web/site/public_html/wp-includes/class-wpdb.php:3088 ; get_col() /var/web/site/public_html/wp-includes/class-wp-query.php:3312 ; get_posts() /var/web/site/public_html/wp-includes/class-wp-query.php:3800 ; query() /var/web/site/public_html/wp-includes/class-wp-query.php:3932 ; __construct() /var/web/site/public_html/wp-content/plugins/bbp-style-pack/blocks/bsp-latest-activity-widget.php:127

    I tried changing between the 3 activity options and toggling on the various options but nothing seemed to help.

    Many Thanks,

    Andy

    @robin-w – If you’re not actively working this, I believe I have a suitable fix for this. It involves:

    1.) Saving the query results for Latest Activity Widget as site transients, and separate transients per activity type (freshness, newness, popular). Then every page load, the quick/light data from the transient is used instead of performing the query every page load.
    2.) Adding a few other query parameters to prevent WP from doing a few extra and unnecessary sub-queries when the query is actually run.
    3.) Minor tweaks to how the query values are built in the first place for code execution speedup.
    4.) Only returning the ‘ids’ field to slim down the query results data since all other displayed values are derived from the ID in the first place.

    It’s not quite that straight-forward, but that’s the gist of it.

    I’m working on these revision right now. I should have something to test later today or tomorrow. @ahillmortons – are you able to replace a single file or two in the bbp_style_pack plugin directory (the File Manager Advanced plugin may be of use)? If so, are you willing to test out these revisions prior to us releasing an official update to address this?

    Plugin Author Robin W

    (@robin-w)

    @codejp3 – that all sounds great, and no I hadn’t started a detailed think about this yet ??

    @ahillmortons
    I have a version ready for you to test.

    The query for Latest Activity has to be run in order to get the info in the first place. There’s really no good way around that.

    With that said:
    1.) the query that gets run has been optimized and minimized any way possible
    2.) it no longer runs every page load for every user
    3.) it only runs when there’s a new topic/reply added to the site, and only the widgets affected by the new topic or reply are re-queried
    4.) it now loads from fast/small site transients by default every page load
    5.) obsolete transients (widgets no longer used) are automatically removed from the DB after 1 month of not being used
    6.) the code-base related to the widget and the query have been slimmed down and optimized

    I setup over 100 various combinations of widgets to test it out on my dev site. Here’s a sample of what the transients look like in wp_options:

    While there are a lot of changes, they all take place in 2 files.

    You can use FTP or the File Manager Advanced plugin to update the following 2 files:

    1.) /wp-content/plugins/bbp-style-pack/blocks/bsp-latest-activity-widget.php

    2.) /wp-content/plugins/bbp-style-pack/includes/widgets.php

    https://codejp3.com/wp-content/uploads/la_widget/bsp_la_widget_update.zip

    If this takes care of the underlying issue like I expect it to, it will be included in the next release of Style Pack.

    Awaiting your feedback.

    • This reply was modified 1 year, 1 month ago by codejp3. Reason: updated download link
    Thread Starter ahillmortons

    (@ahillmortons)

    Hi @codejp3,

    Thanks for taking the time to look into this. I replaced the 2 files as instructed but got a critical error.

    I have rolled back to the original files.

    This is the error shown when I turned on debug:

    Warning: Undefined array key “_wbbBlockId” in /var/web/site/public_html/wp-content/plugins/bbp-style-pack/includes/widgets.php on line 127 Warning: Undefined array key “laShowAuthor” in /var/web/site/public_html/wp-content/plugins/bbp-style-pack/includes/widgets.php on line 127 Warning: Undefined array key “helptext” in /var/web/site/public_html/wp-content/plugins/bbp-style-pack/includes/widgets.php on line 127 Warning: Undefined array key “bbpressOnly” in /var/web/site/public_html/wp-content/plugins/bbp-style-pack/includes/widgets.php on line 127 Fatal error: Uncaught Error: Call to a member function have_posts() on bool in /var/web/site/public_html/wp-content/plugins/bbp-style-pack/blocks/bsp-latest-activity-widget.php:38 Stack trace: #0 /var/web/site/public_html/wp-includes/blocks.php(528): require() #1 /var/web/site/public_html/wp-includes/class-wp-block.php(258): {closure}(Array, ”, Object(WP_Block)) #2 /var/web/site/public_html/wp-includes/class-wp-block.php(244): WP_Block->render() #3 /var/web/site/public_html/wp-includes/class-wp-block.php(244): WP_Block->render() #4 /var/web/site/public_html/wp-includes/blocks.php(1133): WP_Block->render() #5 /var/web/site/public_html/wp-includes/blocks.php(1171): render_block(Array) #6 /var/web/site/public_html/wp-includes/class-wp-hook.php(310): do_blocks(‘

    I’ve taken the widget out of the sidebars for now, but have 2 on this page now the sites are live:

    https://www.model-engineer.co.uk/activity-user/

    Many Thanks,

    Andy

    codejp3

    (@codejp3)

    It was working fine on my dev server, but I do see why you are getting those warnings, and the fatal error they lead to. I revised the code to address that.

    Re-download and replace those 2 files to test it out again.

    1.) /wp-content/plugins/bbp-style-pack/blocks/bsp-latest-activity-widget.php

    2.) /wp-content/plugins/bbp-style-pack/includes/widgets.php

    https://codejp3.com/wp-content/uploads/la_widget/bsp_la_widget_update.zip

    You can see about 10 different examples running on one of my dev sites (bottom widget area). Each widget is a unique variation of Latest Activity:
    https://wp-singlesite.local-dev.codejp3.com/test-subforum/

    BTW, cool site! If I still had a workshop and more free time I’d probably be a regular active member ??

    Thread Starter ahillmortons

    (@ahillmortons)

    Hi @codejp3,

    Thanks again for taking the time to look into this for me.

    I replaced the 2 files but this time the feeds didn’t show on the front of the site at all.

    I have reverted this back to the previous files now and the feed is loading again.

    I’m away until Monday now, so if you reply it will be next week before I pick up my messages again.

    Thank you very much for your assistance.

    Many Thanks,

    Andy

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Object Cache Error on bbp Syle Pack’ is closed to new replies.