-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Block moves to "Inactive widgets" after saving #33335
Comments
I managed to reproduce it – it really does seem to occur at random! So far the most reliable reproduction plan for me is this:
|
It is not easy to repro for me. Can it be a browser thing? I am using Edge and could not get this to happen, with existing or new galleries. |
@draganescu unfortunately this doesn't seem to be a client issue. I debugged the HTTP requests triggered when you save the widgets and it goes like this:
What I noticed is that, when it breaks, both POST requests return the response you would expect, e.g. (notice the What I find interesting though, is that both GET requests return the "broken state" response: This leaves us with three options:
I am currently exploring option 3 as both GET endpoints call |
It may be locking all over again. There are two possible GETs requests
The former only starts when the POST /batch/v1 finishes, this is good and I don't anticipate any problems there. The latter starts immediately after POST /batch/v1 starts, but it is only ever sent if the page was just freshly reloaded, a new widget was added, and we are performing our very first save. This neatly fits the test plan I proposed above and the timing issues hypothesis. |
I still did not manage to capture an active breakpoint exactly when this issue happens organically, but I found that adding a I wonder if this could be a batch processing issue where the next batch request calls |
Reproducing this by hand is tedious and sometimes takes a long, long time. I created a quick&dirty script that sends the same sequence of requests as the widgets editor until it generates the broken state. For me, it happens on my first attempt sometimes, and some other times it needs dozens of attempts. I am not sure what to make of it yet. https://gist.github.com/adamziel/a45b5906700425aab0336a6f1b3ce175 |
I should also mention this is reproducible on WP trunk both with and without the gutenberg plugin. |
I finally managed to figure this one out, it was an interesting one, that's for sure :-) tl;dr The problem is caused by:
full problem description:
Let's take a pause here to find out why does it only affect the last created widget and not all the widgets in the batch. The answer is: Now, so far we're in a fully deterministic world. Request in, bug out. Why is this problem so hard to reproduce then? I'll answer that with a diagram:
I didn't spend any time on cracking the exact sequence of events in that last point, but something mutable is going on in the GET handler so I assume that Anyway, if I remove |
As for a fix – I think each request handler should update all the relevant global variables. With that in mind, the fix here would be as simple as refreshing In addition to that, As a side note, I would absolutely love to get rid of any mutability from |
Let me also surface this from WordPress.org slack:
|
Let's continue the discussion in in https://core.trac.wordpress.org/ticket/53657 |
Actually I'm re-opening this one. We merged a fix for WP core but we may still need to patch the Gutenberg plugin. I initially assumed we don't because there are no @noisysocks do you recall why the |
@adamziel: Just a mistake on my part. I think that the plugin PHP and Core PHP has diverged quite a bit, unfortunately. I wonder if we could make the plugin require WordPress 5.8 sooner. |
I propose we rename |
I poked around and it doesn't seem like the Gutenberg plugin is affected by the problem. The call to The logic of storing and reading widgets is still likely to cause more problems like this one so I created an epic in Trac to sort it out. |
Description
After adding a block to widgets Footer sidebar and saving changes, the widget moves to Inactive widgets area.
This happens randomly. Can be tricky to reproduce.
Step-by-step reproduction instructions
Expected behaviour
The widget should remain in Footer sidebar.
Actual behaviour
The widget is moved to Inactive widgets area.
Screenshots or screen recording (optional)
WordPress information
Device information
The text was updated successfully, but these errors were encountered: