First of all, my current setup is the 7.x-2.x-dev Wysiwig version using the CKEditor v4.5.11 plugin on a 7.50 Drupal installation(it seems that this is valid for higher versions too) with most recent versions of Workbench, Workbench Moderation and Workbench Email.
While editing some node's content, when changing the moderation state in the "Publishing Options" tab to Published I got an error duting the AJAX call as you can check:
The error is actually related to the implementation of Drupal.ajax.prototype.beforeSerialize
in the wysiwyg.js
file on line 864
. After some research I found the implementation of this function in an older Drupal installation inside the misc/ajax.js
on line 282
and the code was indeed similar, but as soon as I searched for the same file on my current Drupal setup, i found a difference as you can see (Ajax.js | Wysiwyg.js):
This explains the error related to the drupal_html_id function expecting a string and receiving an array as the current wysiwyg.js code passes an [] together with the index on the data
. Also you can confirm that this is the problem by checking the docs for the drupal_html_id function, where you can see it retrieving ajax_html_ids from the $POST
superglobal instead of ajax_html_ids[]. We need a patch to fix that situation.
Comment | File | Size | Author |
---|---|---|---|
#3 | ajax_error_1.png | 22.57 KB | davic |
#2 | ajax-workbench-issue-2831460-2.patch | 510 bytes | davic |
code_differences.png | 169.97 KB | davic | |
ajax_error_2.png | 181.87 KB | davic |
Comments
Comment #2
davic CreditAttribution: davic at CI&T commentedJust updated the Summary with the screenshots references. I also created a patch to fix the situation, can anyone please review the issue and the solution provided?
Comment #3
davic CreditAttribution: davic at CI&T commentedUpdating the size of the images on the summary and updated screenshot.
Comment #4
davic CreditAttribution: davic at CI&T commentedComment #5
davic CreditAttribution: davic at CI&T commentedComment #6
maikelfinck CreditAttribution: maikelfinck at CI&T commentedComment #7
maikelfinck CreditAttribution: maikelfinck at CI&T commentedTo enable the AJAX validation when changing the value of "Moderation state" we also need to enable the module
workbench_email
.Comment #8
maikelfinck CreditAttribution: maikelfinck at CI&T commentedComment #9
davic CreditAttribution: davic at CI&T commentedAs an update, i found out directly in the drupal.org docs for the drupal_html_id function that it expects the index 'ajax_html_ids' index instead of 'ajax_html_ids[]', as you can confirm on the documentation provided by looking for code>$_POST['ajax_html_ids'];
Comment #10
TwoDThe screenshot comparing code is not from any Drupal version I know of. The relevant lines in
misc/ajax.js
have not been changed since 2010 and do use the same syntax aswysiwyg.js
does.drupal/misc/ajax.js
lines 310-341:PHP automatically turns multiple POST:ed keys with the same name ending in
[]
into an array once they've reached the server.If the patch suggested here is applied it effectively adds a second parameter containing the filtered list of element ids, while leaving the original list untouched. That pretty much guarantees the server will reject the message due to the excessive amount of POST parameters, the very problem this mechanism is intended to alleviate. This is easily verified by looking at the ajax request's headers in the browser's developer tools.
Could you be more specific as to why you think Wysiwyg is involved in this, and perhaps figure out exactly how old that code sample from core was?