-
Notifications
You must be signed in to change notification settings - Fork 116
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
Create the database tables if they do not exist when resetting the DB #1285
base: develop
Are you sure you want to change the base?
Conversation
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.
@kasparsd I don't believe it's strictly necessary, but it is nice and makes sense that a DB reset would make sure the tables are present and up to date. This is explicit where the other PR is implicit. |
I've been wondering if x+1 plugins with custom tables all do their "TABLE EXISTS" checks, does it have any real performance impact or not. In the big picture, it does seem kind of redundant to guard against a real far-edge case millions of times / year * # of plugins. |
@lkraav for this PR it'll happen when a user clicks a button, as for WP Admin or CLI it's pretty safe. On the frontend it can add up quickly on a busy site |
@@ -673,6 +673,9 @@ public function wp_ajax_reset() { | |||
esc_html__( "You don't have sufficient privileges to do this action.", 'stream' ) | |||
); | |||
} | |||
|
|||
// Create and update the database tables if they do not exist. | |||
$this->plugin->install->check(); |
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.
Is this check here defined( 'DOING_AJAX' ) && DOING_AJAX
going to stop this particular call from doing anything?
stream/classes/class-install.php
Lines 91 to 93 in f541b74
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { | |
return; | |
} |
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 wouldn't have noticed without your help :)
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.
Do you think $this->plugin->install->install( $this->plugin->get_version() );
might make more sense?
Create the database tables if they do not exist when resetting the database
Fixes #1284
If the plugin is loaded without activation, tables are never created and resetting the database does not create tables. This PR changes that so that if tables are missing, a reset creates them.
Checklist
contributing.md
).Release Changelog
Release Checklist
master
branch.readme.txt
.stream.php
.Stable tag
inreadme.txt
.classes/class-plugin.php
.