• Resolved Antony Booker

    (@antonynz)


    On admin pages the https://promo-dashboard.stylemixthemes.com/wp-content/dashboard-promo/ URL for admin notifications is being requested twice on every page view when the UTC / timezone is set to 12 hours or more in the WordPress timezone settings.

    Looking at the code the request is made from these two files:
    cost-calculator-builder/includes/lib/admin-notices/classes/STMDashboard.php
    cost-calculator-builder/includes/lib/admin-notifications-popup/classes/ApiNotifications.php

    The URL request is being stored in a transient with an expiry of 12 hours. However the check below to see if the transient has expired uses the current_time function which will use the timezone set in WordPress, and compares it against the UTC time of the transient timeout, causing the transient to expire prematurely.

        $transient_data       = get_transient( $transient_name );
    
        if ( false === $transient_data || get_option('_transient_timeout_' . $transient_name ) < current_time( 'timestamp' ) ) {

    This results in a 1.6s slow down on the dashboard, whilst WordPress waits for those requests to finish.

    The transient_timeout check can be removed as get_transient only returns a result if the transient hasn’t expired so there’s no need to check the timeout again. After that’s fixed the transient should work as expected and only call it once every 12 hours.

    Additionally the requests will return a 404 URL if the wp-content or plugins folder are using a different folder structure or have been renamed.

    This adds 3s to the admin areas as that’s loading a WordPress 404 page such as below:
    https://promo-dashboard.stylemixthemes.com/wp-content/dashboard-promo/hello-elementor_posts.json

    This is caused by checking if the path of the file is in the wp-content/plugins directory in these two files below, and if not it defaults the URL to use the theme’s slug for the posts.json lookup.

    cost-calculator-builder/includes/lib/admin-notices/admin-notices.php
    cost-calculator-builder/includes/lib/admin-notifications-popup/admin-notification-popup.php

    Would it be possible for the transient fix to be made to prevent those slow downs? The 404 issue isn’t a major as it will be cached if the transient is working.

Viewing 1 replies (of 1 total)
  • Plugin Support Lisa StylemixThemes

    (@lisastylemixthemes)

    Hello,

    Thank you for providing detailed insights into the issue you’re encountering with the admin notifications on the dashboard. It appears that the duplicate requests are stemming from the way the transient timeout is being handled, especially when the WordPress timezone settings exceed 12 hours.

    Removing the transient_timeout check seems like a viable solution since get_transient already ensures that the transient hasn’t expired. This adjustment should streamline the process, ensuring that the request is made only once every 24 hours as intended.

    Regarding the 404 issue, although it adds a delay to the admin areas, it’s somewhat mitigated by caching if the transient is functioning correctly.

    Your suggestion about the relationship between the current time check and timezone settings seems plausible. It’s likely that the inconsistency arises due to timezone discrepancies.

    Rest assured, the discount offer has already concluded, so the popup won’t reappear. Should you have any further concerns or require assistance, feel free to reach out.

    Best regards,
    Lisa

Viewing 1 replies (of 1 total)
  • The topic ‘External requests bugs’ is closed to new replies.