External requests bugs
-
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.
- The topic ‘External requests bugs’ is closed to new replies.