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

Add support for WordPress Multisite #101

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

rafaucau
Copy link
Contributor

@rafaucau rafaucau commented Dec 18, 2024

Resolves #100

@rafaucau rafaucau changed the title fix(multisite): update table prefix after blog switch Add support for WordPress Multisite Dec 18, 2024
@rafaucau
Copy link
Contributor Author

rafaucau commented Dec 18, 2024

When I use:

add_action('switch_blog', function () {
    $this->setTablePrefix($this->db->prefix);
});

This only works partially. It works correctly in the model's getTable() method, but then there's an error when executing the query:

Fatal error: Uncaught Exception: Table 'wordpress.wp_2_wp_2_posts' doesn't exist in wp-orm/src/Orm/Database.php:395

I can't find the place that could be causing generation of a double prefix after executing the setTablePrefix() method. It's not the table method or other similar ones in the Database class.

I'll reset the entire instance:

add_action('switch_blog', function () {
    self::$instance = null;
});

This works correctly.

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 this pull request may close these issues.

[BUG]: Incorrect table prefixes in WordPress Multisite environment
1 participant