Automattic / Automattic/jetpack
Admin Performance: Jetpack Scan Menu Options and Availability Check
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
### Impacted plugin
Jetpack
### Steps to Reproduce
Go to /wp-admin
### A clear and concise description of what you expected to happen.
_No response_
### What actually happened
“Backups & Scans” would very occasionally appear in my Jetpack submenu in wp-admin, even without Backups or Scan active.
### Other information
My test site doesn’t have Jetpack Scan or Backup — I will have to test with these features another time, but my focus on this round was around base Jetpack.
However, I noticed that “Backups & Scans” would very occasionally appear in my Jetpack submenu in wp-admin.
After some digging, I found that it depends on a transient called jetpack_scan_state, [which only lives for up to 30 minutes](https://href.li/?https://github.com/Automattic/jetpack/blob/master/projects/plugins/jetpack/_inc/lib/class.core-rest-api-endpoints.php#L1715). When the transient isn’t present or has timed out, [the admin side-bar acts as though the user has Jetpack Scan enabled](https://href.li/?https://github.com/Automattic/jetpack/blob/master/projects/plugins/jetpack/modules/scan/class-admin-sidebar-link.php#L157). This adds both the menu item and a bunch of extra resources to the page. It then schedules a wp-cron job to refresh the transient on a subsequent page-load.
You can replicate this behavior by deleting the transient and loading any wp-admin page.
I recommend:
- Extend the life of the Jetpack Scan transient, and
- Look for ways to avoid loading Jetpack Scan resources for sites without the feature.
Internal reference: p1HpG7-evU-p2
### Operating System
_No response_
### OS Version
_No response_
### Browser
Chrome/Chromium
### Browser Version(s)
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.