| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
@merkys7 Left some feedback.
Sorry, something went wrong.
There was a problem hiding this comment.
@merkys7 Thanks for the updates. The approach here now looks good, Left some more feedback.
Sorry, something went wrong.
| * | ||
| * @since n.e.x.t | ||
| */ | ||
| function delete_data() { |
There was a problem hiding this comment.
As per the plugin function name we should use the perflab_ prefix in name of the function. Something like perflab_delete_option or perflab_delete_plugin_option.
cc. @felixarntz
Sorry, something went wrong.
There was a problem hiding this comment.
do we really need a helper function for one line of code?
Sorry, something went wrong.
There was a problem hiding this comment.
In my initial approach, I don't use a helper function for a single line: #345 (comment) But I think it was used two times, so Merkys introduced a helper function. If it doesn't make sense, then can we remove it?
Sorry, something went wrong.
There was a problem hiding this comment.
Thank you for the feedback, removed it
Sorry, something went wrong.
There was a problem hiding this comment.
Not a blocker, but I also prefer to have a function for this. Yes, it's one line, but IMO it makes sense even to have a function for this to clarify that this needs to be exactly the same logic for a single site as well as for every site in a multisite. Plus it avoids a (admittedly tiny) chance of e.g. a typo in the option name in one of the calls, which in a function call would immediately be flagged as fatal error, but in a string isn't.
Sorry, something went wrong.
There was a problem hiding this comment.
left some questions/feedback
Sorry, something went wrong.
|
I really appreciate your feedback @mukeshpanchal27 @adamsilverstein |
Sorry, something went wrong.
There was a problem hiding this comment.
@merkys7 Thanks for the updates. It looks good. I left some final feedback.
Sorry, something went wrong.
| } | ||
|
|
||
| delete_option( 'perflab_modules_settings' ); | ||
| if ( is_multisite() && 100 >= get_sites( array( 'count' => true ) ) ) { |
There was a problem hiding this comment.
I feel like we should check the count condition inside the loop. Otherwise, it will run else part for multisite with more than 100 sites.
Sorry, something went wrong.
There was a problem hiding this comment.
I would argue we don't need that check for the site count here at all. It's another query to run, which we can avoid. I think we should still handle multisites in the right way, and we can just limit the get_sites() query like you do below. That means:
The latter is not great, but better than what we currently have, while accounting for scalability issues. Also, deleting the option for 100 sites when there are more is still better than falling back to only deleting the option for the current site.
Sorry, something went wrong.
There was a problem hiding this comment.
Also, let's add a comment here explaining this block.
| if ( is_multisite() && 100 >= get_sites( array( 'count' => true ) ) ) { | |
| // For a multisite, delete the option for all sites (however limited to 100 sites to avoid memory limit or timeout problems in large scale networks). | |
| if ( is_multisite() ) { |
Sorry, something went wrong.
There was a problem hiding this comment.
@merkys7 Thank you for the PR! Left some comments with additional suggestions.
Sorry, something went wrong.
| } | ||
|
|
||
| delete_option( 'perflab_modules_settings' ); | ||
| if ( is_multisite() && 100 >= get_sites( array( 'count' => true ) ) ) { |
There was a problem hiding this comment.
I would argue we don't need that check for the site count here at all. It's another query to run, which we can avoid. I think we should still handle multisites in the right way, and we can just limit the get_sites() query like you do below. That means:
The latter is not great, but better than what we currently have, while accounting for scalability issues. Also, deleting the option for 100 sites when there are more is still better than falling back to only deleting the option for the current site.
Sorry, something went wrong.
| } else { | ||
| delete_option( 'perflab_modules_settings' ); | ||
| } |
There was a problem hiding this comment.
I think it would be best to not have this in an else, but instead always run it. IMO it makes sense to at least always wipe the current site's (main site) option on uninstall. If a multisite has more than 100 sites, we should still ensure the main site's option is deleted.
So I would suggest the following:
| } else { | |
| delete_option( 'perflab_modules_settings' ); | |
| } | |
| } | |
| // Delete the current site's option. | |
| delete_option( 'perflab_modules_settings' ); |
Sorry, something went wrong.
| } | ||
|
|
||
| delete_option( 'perflab_modules_settings' ); | ||
| if ( is_multisite() && 100 >= get_sites( array( 'count' => true ) ) ) { |
There was a problem hiding this comment.
Also, let's add a comment here explaining this block.
| if ( is_multisite() && 100 >= get_sites( array( 'count' => true ) ) ) { | |
| // For a multisite, delete the option for all sites (however limited to 100 sites to avoid memory limit or timeout problems in large scale networks). | |
| if ( is_multisite() ) { |
Sorry, something went wrong.
|
Thank you for the feedback guys |
Sorry, something went wrong.
There was a problem hiding this comment.
@merkys7 Thank you for the updates, looks great now! I found one more issue that needs to be addressed.
Small aside: Please avoid force-pushing. Preferably you would simply add commits with your changes to this PR. Otherwise it messes up the git history.
Sorry, something went wrong.
There was a problem hiding this comment.
@merkys7 Made the final mini updates here, so this is good to go into 1.4.0 now. Thanks again!
Sorry, something went wrong.
|
@felixarntz Thank you for the help and feedback! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #382
Relevant technical choices
Remove plugin option for Multisite during uninstall execution
Checklist