• Resolved ant42

    (@ant42)


    Hi,

    I’m creating reviews programmatically using glsr_create_review() with assigned_posts specified:

    $review_data = array(
    'assigned_posts' => array(42),
    'form' => 646,
    'rating' => 5,
    );
    $review = glsr_create_review($review_data);

    However, WP-Optimize integration is purging the entire site cache instead of just the cache for post #42.

    Questions:

    1. Is this the expected behavior when creating reviews via PHP?
    2. Should only the assigned post’s cache be cleared, not the entire cache?
    3. Is there a proper way to create reviews programmatically that will correctly flush only the relevant page cache?

    Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Paul

    (@pryley)

    1. Go to the Site Reviews > Tools > Console page and change the log level to “Debug”
    2. Clear the console log
    3. Programmatically create a review
    4. Refresh the console log
    5. Post the results of the console log here
    Thread Starter ant42

    (@ant42)

    [2025-10-04 13:14:05] DEBUG [Integrations\Cache\Controller:95] cache::flush_after_post_cache_cleaned
    [2025-10-04 13:14:05] DEBUG [Integrations\Cache\Controller.php:112] cache::flushing [all]
    [2025-10-04 13:14:05] DEBUG [Integrations\Cache\Controller:23] cache::flush_after_review_created
    [2025-10-04 13:14:05] DEBUG [Integrations\Cache\Controller.php:112] cache::flushing [all]

    Plugin Contributor Paul

    (@pryley)

    Looks like a bug. I’ll look into it.

    Thread Starter ant42

    (@ant42)

    Thank you for the quick response!

    Just wanted to add: the same issue happens when I simply click “Add New Review” in admin – entire cache is purged even before saving anything.

    Plugin Contributor Paul

    (@pryley)

    What should happen in the following case?

    1. You have one or more pages on your website that display reviews.
    2. There is a separate “submit review” page where reviews are submitted.
    3. Reviews are unassigned to pages (but could be assigned to categories).
    4. When a review is submitted on the “submit review” page, due to the modular nature of Site Reviews, it has no way of knowing which page cache to flush because the submitted review is unassigned.

    In this scenario, is it better to flush the entire cache or not flush at all?

    And if not at all, how do you prevent support requests from people who say that Site Reviews is not working because new reviews do not appear on their cached pages?

    Thread Starter ant42

    (@ant42)

    I think flushing the entire cache makes sense in that scenario – better than having stale content.

    I noticed that cache is purged when opening the “Add New Review” page (/wp-admin/post-new.php?post_type=site-review), rather than when actually saving/publishing a review – thought I’d mention it in case it’s unintended.

    For me it’s not a critical issue since I only add reviews with assigned posts. In my case, I’d prefer to flush cache only for those assigned pages rather than the entire site. Or alternatively, disable the full cache purge via hook and clear specific pages programmatically. Please let me know if there’s a way to do this!

    • This reply was modified 8 months ago by ant42.
    Plugin Contributor Paul

    (@pryley)

    thought I’d mention it in case it’s unintended.

    It is unintended and it is happening due to the same bug.

    This will be fixed in Site Reviews v8.0

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Full cache purge when creating review programmatically with glsr_create_review()’ is closed to new replies.