-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update SiteCapabilities
to use Transient
class
#99
Conversation
TBH I'm not sure this is needed, but a test was.
includes/Helpers/Transient.php
Outdated
*/ | ||
public static function should_use_transients() { | ||
protected static function should_use_transients(): bool { | ||
require_once constant( 'ABSPATH' ) . '/wp-admin/includes/plugin.php'; | ||
return ! array_key_exists( 'object-cache.php', get_dropins() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BrianHenryIE - We should probably update the logic here. This is true for shared hosting where there is no object cache, but now that we have Bluehost Cloud that does have object caching, we should take this into account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proposed changes
The
Transient
class was created to address an issue where sites have an object cache present which breaks transients on the site. E.g. when a site has migrated in and continues to try to use a Redis instance that does not exist. It works by detectingobject-cache.php
and usingwp_options
table for transients if that is present.The
SiteCapabilities
class was not using this implementation.This PR updates
SiteCapabilities
to use theTransient
class, and adds tests for both classes.There is a small break where currently the
wp_options
based transients are stored with anexpires
key which has been renamed toexpires_at
. This means the transients will returnfalse
the next time they are fetched and then once set again will work as expected.Type of Change
Video
Checklist
Further comments
get_transient()
etc. rather than theTransient
classWP_Object_Cache
as a global solution to the transient issueset_transient()
etc in theNewfoldLabs\WP
namespace hoping calls from insideNewfoldLabs\WP\Module\Data\*
would use that rather than\set_transient()
but it only works for the same namespace and skips functions defined in intermediate namespaces