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

Stream does not check database tables exist #1284

Closed
tomjn opened this issue Sep 16, 2021 · 10 comments · May be fixed by #1285
Closed

Stream does not check database tables exist #1284

tomjn opened this issue Sep 16, 2021 · 10 comments · May be fixed by #1285

Comments

@tomjn
Copy link
Contributor

tomjn commented Sep 16, 2021

Bug Report

Stream only creates database tables on plugin activation, then never checks they exist.

Expected Behavior

Use Stream in an environment here plugin activation occurs.

Stream sees that the tables don't exist and creates them.

Actual Behavior

Stream does not create the tables because you did not load the plugin by activating it.

Additionally, the reset database tables link in settings does not create the tables if they do not exist

Steps to Reproduce the Problem

  1. Install Stream using a method that does not involve plugin activation. E.g. as an MU Plugin
  2. Try to use it
  3. Be constantly told that the database tables do not exist

System Information

  • Stream plugin version:
  • WordPress version: 5.8
  • PHP version: 7.4
  • Browser: Chrome
  • Computer operating system: Linux

If making it auto-check isn't possible, providing a way to create the tables would also be great. Right now this is extremely frustrating and regularly causes problems with local environments on multiple projects.

@tomjn tomjn changed the title Checking tables exist i Stream does not check database tables exist Sep 16, 2021
@tomjn
Copy link
Contributor Author

tomjn commented Sep 16, 2021

Working around this I got:

wp_stream_get_instance()->install->check();

Running that code once created the tables

@tomjn
Copy link
Contributor Author

tomjn commented Sep 16, 2021

I made a quick PR that adds them when the DB resets, however, the Install class should check on these situations too:

  • wp admin requests
  • wp cli requests

tomjn added a commit to tomjn/stream that referenced this issue Sep 16, 2021
@kasparsd
Copy link
Contributor

Thanks for reporting the issue @tomjn!

This appears to be related to this very recent change #1201 which was attempting to fix this issue #1169

What would be the most performant way of ensuring the tables exist if we’re doing that on pretty much every request?

Could we use an option to store the schema revision once the tables are created and then assume that the tables are present while the options is there?

@tomjn
Copy link
Contributor Author

tomjn commented Sep 16, 2021

@kasparsd see my last PR, it only checks on WP Admin/CLI requests, avoiding the issue you linked to

@tomjn
Copy link
Contributor Author

tomjn commented Sep 16, 2021

the reset PR also provides a manual way to fix this

@tomjn
Copy link
Contributor Author

tomjn commented Sep 16, 2021

#1285 and #1286 specifically

@kasparsd
Copy link
Contributor

@tomjn Can we assume this is now fixed with #1286 being merged?

@tomjn
Copy link
Contributor Author

tomjn commented Sep 17, 2021

@kasparsd yes, just need a release with it in and I'll have some very happy people :) Closing

@tomjn tomjn closed this as completed Sep 17, 2021
@kasparsd
Copy link
Contributor

Thanks for the confirmation and your contribution! I'll create a release either today or early next week.

@kasparsd
Copy link
Contributor

@tomjn 3.8.1 is out now:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants