Skip to content
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

Merged
merged 2 commits into from Oct 2, 2017

Conversation

enejb
Copy link
Member

@enejb enejb commented Sep 27, 2017

In some cases it might be better if we bypassed that option to get the raw info.

Changes proposed in this Pull Request:

  • Allows other devs to define constants and filters that lets them define which options should be allows to be set directly.

Testing instructions:

  • Do the tests pass?

Proposed changelog entry for your changes:

@enejb enejb added [Package] Sync [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Sep 27, 2017
@enejb enejb added this to the 5.4 milestone Sep 27, 2017
@enejb enejb self-assigned this Sep 27, 2017
@enejb enejb requested a review from a team as a code owner September 27, 2017 21:10
* @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] );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing spaces around $name

*/
static function by_pass_raw_option( $name ) {

if ( Jetpack_Constants::get_constant( 'JETPACK_DISABLE_RAW_OPTION' ) ) {
Copy link
Contributor

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?

*
* @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() );
Copy link
Contributor

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

return true;
}
/**
* Allows us to disable the some raw options.
Copy link
Contributor

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.

* @since 5.5.0
*
*
* @param array $disabled_raw_options has the key set of the option that you want to disable
Copy link
Contributor

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?

Copy link
Member

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.

@@ -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.
Copy link
Contributor

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?

Copy link
Member

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."

@@ -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 ) ) {
Copy link
Contributor

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

@lezama
Copy link
Contributor

lezama commented Sep 28, 2017

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.

@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Sep 28, 2017
In some cases it might be better if we bypassed that option to get the raw info.
@zinigor zinigor force-pushed the fix/add-constant-to-disable-raw-options branch from cdd7016 to cd074ea Compare September 28, 2017 13:20
@zinigor
Copy link
Member

zinigor commented Sep 28, 2017

Rebased the PR to get around the problem with Twitter shortcode tests, Travis should pass now.

@@ -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.
Copy link
Member

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."

* @since 5.5.0
*
*
* @param array $disabled_raw_options has the key set of the option that you want to disable
Copy link
Member

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
@enejb
Copy link
Member Author

enejb commented Sep 29, 2017

Updated with the suggested fixes. Thanks for the review @lezama and @roccotripaldi !

@enejb enejb added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Sep 29, 2017
Copy link
Contributor

@lezama lezama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🙇

@enejb enejb merged commit 9904c57 into master Oct 2, 2017
@enejb enejb deleted the fix/add-constant-to-disable-raw-options branch October 2, 2017 19:12
@matticbot matticbot removed the [Status] Needs Review To request a review from Crew. Label will be renamed soon. label Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants