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

Tables wp_p2p and wp_p2pmeta not created upon plugin activation #555

Open
Flimm opened this issue Oct 5, 2017 · 2 comments
Open

Tables wp_p2p and wp_p2pmeta not created upon plugin activation #555

Flimm opened this issue Oct 5, 2017 · 2 comments

Comments

@Flimm
Copy link

Flimm commented Oct 5, 2017

Let's say that I install the "Posts 2 Posts" plugin on a brand new WordPress installation, using the WP CLI, like this:

$ wp plugin install --activate posts-to-posts
Installing Posts 2 Posts (1.6.5)
Downloading install package from https://downloads.wordpress.org/plugin/posts-to-posts.1.6.5.zip...
Using cached file '.wp-cli/cache/plugin/posts-to-posts-1.6.5.zip'...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Activating 'posts-to-posts'...
Plugin 'posts-to-posts' activated.
Success: Installed 1 of 1 plugins.

At this point, the plugin has been installed and activated. However, the tables have not been created yet:

> show tables;
+-----------------------+
| Tables_in_dt          |
+-----------------------+
| wp_commentmeta        |
| wp_comments           |
| wp_links              |
| wp_options            |
| wp_postmeta           |
| wp_posts              |
| wp_term_relationships |
| wp_term_taxonomy      |
| wp_termmeta           |
| wp_terms              |
| wp_usermeta           |
| wp_users              |
+-----------------------+

As you can see, the tables wp_p2p and wp_p2pmeta are missing. If there are any other plugins that depend on this functionality, this could cause errors like this one to appear:

WordPress database error: [Table 'wordpress.wp_p2p' doesn't exist]

Based on reading the source code, it looks like the tables are created when an instance of the class P2P_Tools_Page is created for the first time here:

new P2P_Tools_Page;

This is inside the function _p2p_load_admin, which is only called if is_admin() is true. Instead, the tables should be created upon plugin registration.

Of course, the workaround is to visit the WordPress admin before using the site. Sure enough, as soon as the WordPress admin dashboard is visited, the tables are created.

Requiring visiting the WordPress admin makes it harder to automate setting up new websites with certain plugins using the WP CLI.

@dylanjameswagner
Copy link

@Flimm Were you able to find a solution to this issue?

@Flimm
Copy link
Author

Flimm commented Feb 15, 2018

I've just been using the workaround mentioned in the issue description.

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

No branches or pull requests

2 participants