-
Notifications
You must be signed in to change notification settings - Fork 157
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
Consider multisite for post abstraction. #1007
Comments
I created a mini-plugin to get some timing notes, times below are for the full number of runs, not averaged. Multisite testsConstructor only
Single site testsConstructor only
|
The one liner for this bug is: after running After doing various tests I see the following solutions: Use statics and pre-populate the data on multisite installs 60d805d Pros:
Cons:
Check current site and switch if needed 5c93a48 Pros:
Cons:
Warn/fatal if using a helper method while the site is switched I don't have any code for this but pretty much what it says on the pack, throw if someone tries to use a helper method while they've switched site. Pros
Cons
FWIW, I don't think this is a good idea. If the issue is solvable via defensive coding then we should do so. For one of the earlier suggestions, I might be able to be convinced to throw a notice for the performance impact. |
I've read through the above a few times but don't necessarily have a great opinion on the best approach. I'm not opposed to the first approach where we're using statics but it's not a great pattern to follow and as mentioned, pretty hard to test. But seems like the best from a performance prospective. I'm wondering if this line |
Describe the bug
Network connections make heavy use of the
switch_to_blog()
function. With regard to the post abstraction, this can be problematic if a helper method is called after switching blogs as the returned data can be a mix of content from the original site's post and the switched site's post.For the methods within the post abstraction, it would be good to ensure the data always comes from the site used when the post abstraction was created.
Steps to Reproduce
develop
branch.Edited sample posts title
Note that after switching to site two, the
$dt_post
variable is returning a mix of data from the primary and secondary siteScreenshots, screen recording, code snippet
No response
Environment information
No response
WordPress information
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: