The goal of this PR is to change when we issue queries to the API server for releases metadata, and how we store it.
The big idea is that we want to (almost) never issue a synchronous network request from the WordPress server to the Font Awesome API server to load releases metadata on normal front end page loads. In fact, we only ever want to issue that request when:
an admin user loads the settings page (and even then, we only do it when it's been a while)
upgrading, and only when necessary
So we'll store the releases metadata in a normal option, instead of a transient. Thus it will not expire, and should never be automatically "cleaned up" as transients may sometimes.
We also don't want to load all of that releases metadata into the PHP process memory unless we need it, and we very rarely need it. We definitely don't want to autoload all of that data, especially because we never need it when Using a Kit. And when we're Using a CDN, we really only need to load it when the admin user needs to know the options for changing the version selection. But on the vast majority of loads, we only need releases metadata for the current configured version, which is almost always the last used.
So we'll store just the metadata for that last used release in a transient. Therefore, on most page loads when Using CDN, we won't load the whole releases metadata at all--just the metadata for last used release.
[x] do not throw exception when set_site_transient() returns false saving the last used transient
[x] store releases metadata in a non-expiring option, instead of an expiring transient
[x] never auto-refresh releases
[x] re-evaluate whether to refresh_releases() in try_upgrade()
[x] confirm release metadata is refreshed when loading settings page
[x] probably remove fa()->refresh_releases() from public API, or at least guard against its running on a front end page load
[x] Add a notice to FontAwesome class API methods for those that would trigger the loading of all metadata, such as latest_version().
[x] Don't throw an exception on front end page loads if the releases metadata are missing. Do show some kind of alert on the admin dashboard if the metadata are missing.
[x] Integration Testing: Ensure that all releases metadata are not loaded unless used
normal front end page loads should never need to load it, even when configured for Use CDN. Only the last used transient would need to be loaded.
try_upgrade() should not load releases metadata, exception for the single occurrence when the upgrade is necessary
[x] ensure that the font-awesome-releases option is not autoloaded
The goal of this PR is to change when we issue queries to the API server for releases metadata, and how we store it.
The big idea is that we want to (almost) never issue a synchronous network request from the WordPress server to the Font Awesome API server to load releases metadata on normal front end page loads. In fact, we only ever want to issue that request when:
So we'll store the releases metadata in a normal option, instead of a transient. Thus it will not expire, and should never be automatically "cleaned up" as transients may sometimes.
We also don't want to load all of that releases metadata into the PHP process memory unless we need it, and we very rarely need it. We definitely don't want to autoload all of that data, especially because we never need it when Using a Kit. And when we're Using a CDN, we really only need to load it when the admin user needs to know the options for changing the version selection. But on the vast majority of loads, we only need releases metadata for the current configured version, which is almost always the last used.
So we'll store just the metadata for that last used release in a transient. Therefore, on most page loads when Using CDN, we won't load the whole releases metadata at all--just the metadata for last used release.
latest_version()
.