I faced the ajax crush issue on views_pdf. Issue is with the latest drupal verion 7.39 and 7.40 so if user upload the pdf file then ajax crushed and show message
CustomMessage: The response failed verification so will not be processed.

Views_pdf using Views module api so I found the following details:

Views is passing wrong url to ajax which does not match the Drupal.settings.urlIsAjaxTrusted e,g
Views ajax.url: http://drupal740.local/admin/structure/views/ajax/display/views_pdf/pdf_...
Drupal.settings.urlIsAjaxTrusted : {"/admin/structure/views/view/views_pdf/edit/pdf_1?render=overlay":true,"/admin/structure/views/view/views_pdf/preview/pdf_1/ajax":true,"/admin/structure/views/view/views_pdf/preview/pdf_1":true,"/admin/structure/views/ajax/display/views_pdf/pdf_1/pdf_template":true}

In the above scenario Drupal ajax does not pass it and crush the response

/misc/ajax.js line number 183
if (response !== null && !Drupal.settings.urlIsAjaxTrusted[ajax.url]) {
        if (xmlhttprequest.getResponseHeader('X-Drupal-Ajax-Token') !== '1') {
          var customMessage = Drupal.t("The response failed verification so will not be processed.");
          return ajax.error(xmlhttprequest, ajax.url, customMessage);
        }
      }

We can resolve this by changing this line of code

Current views/includes/ajax.inc line number 268:

    $url = empty($form_state['url']) ? url($_GET['q'], array('absolute' => TRUE)) : $form_state['url'];

Should be:

    $url = empty($form_state['url']) ? request_uri() : $form_state['url'];

Comments

asghar created an issue. See original summary.

asghar’s picture

Assigned: asghar » Unassigned
Status: Needs review » Active
asghar’s picture

StatusFileSize
new483 bytes
kala4ek’s picture

Version: 7.x-3.11 » 7.x-3.x-dev
Status: Active » Needs review
vegansupreme’s picture

This patch solves the problem in Views PDF for me. I wonder if there are other Views related modules having a similar problem?

asghar’s picture

If other modules are using the file field attachment in settings as views_pdf then they will definitely face the same issue.

vegansupreme’s picture

I vote for this solution. Any idea why the test isn't working?

steven jones’s picture

I'm not 100% sure it's the same issue, but I think it might be: #2572117: Unable to change settings in views after Drupal upgrade which, has a different patch, that might also fix this issue.

troybthompson’s picture

This solved my problem with views_pdf

chris matthews’s picture

The 3 year old patch in #3 to ajax.inc applied cleanly to the latest views 7.x-3.x-dev and appears to be ready to RTBC.