Description
Description
The publish button blinks after editing plugins on some projects, and completely disappears on others.
Steps to reproduce
Use django newer than 2.2.19 and any django-cms version newer than September 2014. Create a text plugin. Edit the text plugin. In most cases you will notice the publish button blink. In rare occasions (in some project not so rare, almost always) the publish button disappears and does not return until you refresh the page.
Expected behaviour
Editing plugins should not make the publish button disappear or blink.
Technical Description
After editing a plugin, django-cms' frontend makes two requests to the server. One to get the toolbar, and one to get the current page's contents. Using the response from both of them, the toolbar's contents are being replaced. The toolbar contents are replaces twice, I don't know why. The request that fetches the toolbar alone is broken and lacks the publish button in its response. The one that fetches the current page's contents is ok. These requests are executed asynchronously. Almost always, the request that fetches the toolbar finishes first, and the request that fetches the entire page's contents finishes second. This usually hides the problem with the missing publish button from the request that fetches the toolbar. You can notice the publish button blinking after editing a text plugin for example. But on some projects they finish in reversed order, and the page ends up missing the publish button.
The request that fetches the toolbar contents needs to be fixed. I have a working solution, but I want to avoid breaking other things, so I need your input. I will first explain below what and why is happening.
The request that fetches the toolbar contents is supplying a list of placeholders in the url's GET variables. As a solution to issue 3404, all the &
characters in the URL are replaced with &
. This worked for a time, mainly due to luck, but since django 2.2.19 it doesn't anymore. When placeholders[]=12&placeholders[]=13&placeholders[]=14
is replaced with placeholders%5B%5D=12&placeholders%5B%5D=13&placeholders%5B%5D=14
, the GET variables on django's side used to be parsed to this {'placeholders[]': ['12', '13', '14'], 'amp': ['', '', '']}
because both the "&" and the ";" characters were used as query separators. And the request was working properly. But in Django version 2.2.19, ";" was removed as a query separator, and since then, this feature is broken. The example from above ends up being parsed like this: {'placeholders[]': ['12'], 'amp;placeholders[]': ['13', '14']}
and I can see some other weird contents in there, but it seems they aren't breaking anything yet.
Proposed solution
Do not replace "&" with "&" in the full URL string. Would this bring back the problems of issue 3404? I have created a PR with this change. I have tested it and was unable to reproduce the problem reported in issue 3404. Please review this and let me know if you have other suggestions.
Additional information
This happens on django versions newer than 2.2.19, and django-cms versions since September 2014.