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
jetpack raw option: Add a way to bypass it #7875
Conversation
class.jetpack-options.php
Outdated
* @param array $disabled_raw_options has the key set of the option that you want to disable | ||
*/ | ||
$disabled_raw_options = apply_filters( 'jetpack_disabled_raw_option', array() ); | ||
return isset( $disabled_raw_options[$name] ); |
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.
missing spaces around $name
class.jetpack-options.php
Outdated
*/ | ||
static function by_pass_raw_option( $name ) { | ||
|
||
if ( Jetpack_Constants::get_constant( 'JETPACK_DISABLE_RAW_OPTION' ) ) { |
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.
should this be JETPACK_DISABLE_RAW_OPTIONS
?
class.jetpack-options.php
Outdated
* | ||
* @param array $disabled_raw_options has the key set of the option that you want to disable | ||
*/ | ||
$disabled_raw_options = apply_filters( 'jetpack_disabled_raw_option', array() ); |
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.
jetpack_disabled_raw_option
=> jetpack_disabled_raw_options
class.jetpack-options.php
Outdated
return true; | ||
} | ||
/** | ||
* Allows us to disable the some raw options. |
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.
Allows us to disable the some raw options.
=> Allows to disable particular raw options.
class.jetpack-options.php
Outdated
* @since 5.5.0 | ||
* | ||
* | ||
* @param array $disabled_raw_options has the key set of the option that you want to disable |
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.
I think this needs better English, cc @roccotripaldi could you help us here?
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.
An array of option names that you can selectively blacklist from being managed via direct database queries.
class.jetpack-options.php
Outdated
@@ -404,4 +414,27 @@ static function get_raw_option( $name, $default = null ) { | |||
return $value; | |||
} | |||
|
|||
/** | |||
* This function lets us by pass certain options to be gotten via the raw sql calls. |
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.
I think this needs better English, cc @roccotripaldi could you help us here?
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.
"This function checks for a constant that, if present, will disable direct DB queries Jetpack uses to manage certain options and force Jetpack to always use Options API instead.
Options can be selectively managed via a blacklist by filtering option names via the jetpack_disabled_raw_option
filter."
class.jetpack-options.php
Outdated
@@ -337,6 +337,9 @@ private static function delete_grouped_option( $group, $names ) { | |||
* @return bool Is the option deleted? | |||
*/ | |||
static function delete_raw_option( $name ) { | |||
if ( self::by_pass_raw_option( $name ) ) { |
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.
allover we need to change by_pass
to bypass
Great idea @enejb! Just left some minor comments around language, code looks great to me! 5.3 tests where failing but seemed unrelated to this PR, I just clicked the button to run them again. |
In some cases it might be better if we bypassed that option to get the raw info.
cdd7016
to
cd074ea
Compare
Rebased the PR to get around the problem with Twitter shortcode tests, Travis should pass now. |
class.jetpack-options.php
Outdated
@@ -404,4 +414,27 @@ static function get_raw_option( $name, $default = null ) { | |||
return $value; | |||
} | |||
|
|||
/** | |||
* This function lets us by pass certain options to be gotten via the raw sql calls. |
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.
"This function checks for a constant that, if present, will disable direct DB queries Jetpack uses to manage certain options and force Jetpack to always use Options API instead.
Options can be selectively managed via a blacklist by filtering option names via the jetpack_disabled_raw_option
filter."
class.jetpack-options.php
Outdated
* @since 5.5.0 | ||
* | ||
* | ||
* @param array $disabled_raw_options has the key set of the option that you want to disable |
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.
An array of option names that you can selectively blacklist from being managed via direct database queries.
improved english and monor fixes
Updated with the suggested fixes. Thanks for the review @lezama and @roccotripaldi ! |
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.
Thanks 🙇
In some cases it might be better if we bypassed that option to get the raw info.
Changes proposed in this Pull Request:
Testing instructions:
Proposed changelog entry for your changes: