When changing settings specific to Views PDF, after clicking "apply" it results in a long AJAX error message starting with:

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: http://mysite.dev/admin/structure/views/ajax/display/another_test_pdf/pd...
StatusText: n/a
CustomMessage: The response failed verification so will not be processed.
ResponseText: [{"command":"settings","settings":"

I suspect this is related to https://www.drupal.org/SA-CORE-2015-003

On the below page it explains how to have your code manually validate the URL.
https://www.drupal.org/drupal-7.39-release-notes

I'm not sure where to begin to fix this.

Comments

vegansupreme created an issue. See original summary.

troybthompson’s picture

For now, I've downgraded to Drupal 7.38, but I'm free to test things when there's a patch.

Feprabel’s picture

Hi, I have exactly the same problem.
Does anybody found how to fix it ?
I don't like the idea to downgrade to Drupal.38 and maybe cause other issues

Anonymous’s picture

I fixed this by adding the following function to your Ajax callback function:

ajax_set_verification_header();

vegansupreme’s picture

@bpcarlsen, can you be specific about where that code goes? Does it go somewhere in views_pdf code? I'm not familiar with AJAX in Drupal. Can you make a patch?

argiepiano’s picture

For what it's worth: I haven't figured out how to fix the error message. Still, while the error is annoying, all changes to the settings can actually be saved. After making the changes and clicking Apply (you'll get the error - click OK), navigate away from the Views PDF Display, for example, by clicking on the Views link in the breadcrumbs. Then go back to the View - it will show unsaved changes. Click Save to save the new settings. The Ajax call is there only to update the settings window, it does not interfere with the functioning of Views PDF.

asghar’s picture

Hi All

I have resolved the issue and attached the patch. Actually issue is related to views so you can read further details on views issue page https://www.drupal.org/node/2595607. Thanks

asghar’s picture

Don't be confused .. you can resolve this issue by implemented one of the patch either views_pdf patch ( views_pdf-ajax-error-verificatin-failed-2563263.patch) or views patch https://www.drupal.org/node/2595607. Don't try to implement both. Thanks

asghar’s picture

Status: Active » Needs review
vegansupreme’s picture

Status: Needs review » Needs work

Asghar,
I'm still getting an error when submitting the form, albeit a much shorter error. I haven't tried the views patch yet. I'll comment on that issue with my results.
Thanks for looking into this! I've been stumped!

For reference, here's the error I got:
An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: http://www.viewspdf.dev/admin/structure/views/ajax/display/my_view/pdf_1...
StatusText: n/a
CustomMessage: The response failed verification so will not be processed.
ResponseText: [{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"seven","theme_token":"e-aSHkQgZ6PPGAFwFkL0tJ1XBcSennh86jOe2gQmqlw","jquery_version":"1.5"},"urlIsAjaxTrusted":{"\/admin\/structure\/vie

asghar’s picture

Could you attach the module?. I want to see code. Thanks

vegansupreme’s picture

StatusFileSize
new3.46 KB

What do you want me to attach? Here's an export of my test view.

asghar’s picture

StatusFileSize
new106.13 KB

I tested the patch on the following environment and scenario.

Drupal versoin: 7.40
Views_pdf: 7.x-1.4

I uploaded the pdf file and submit the settings. Settings saved successfully. See screen short.
Views_pdf settings

vegansupreme’s picture

There's no error on PDF Template settings, but the error I got was on "PDF Fields | Settings". Maybe the same fix needs to be applied to views_pdf_plugin_row_fields.inc?
I tried the patch you posted to #2595607: Passing wrong URL to ajax.url and that patch works in all cases as far as I can tell. So maybe that's the better place for the fix.

asghar’s picture

Maybe the same fix needs to be applied to views_pdf_plugin_row_fields.inc?

Asghar: Yes we can fix this by implementing same snippet.

or
We implement the views patch.

killua99’s picture

Last comment on the views issue said to use that solution, So which one look the best?

vegansupreme’s picture

The Views solution looks better to me. It's a smaller, more upstream solution. And it could fix the same problem in other modules—though I haven't seen other modules having that problem. We'd have to be sure it doesn't introduce regressions in Views. I'd feel better if it passed automated testing, but the tests haven't been run. I'm not sure how to trigger them. Then we have to convince Views maintainers to commit it.

The Views PDF only solution we could commit right away, and regressions, if any would be limited to Views PDF.

troybthompson’s picture

I used the views patch and that worked for me.

RedsMK’s picture

I used the views patch and that worked for me too.

vegansupreme’s picture

Looks like nothing is happening in Views on this issue. I say we commit the patch here, if they do update Views, we can always revert. This is an annoying bug, I hope to be able to commit this patch soon.

vegansupreme’s picture

Here's asghar's patch also applied to views_pdf_plugin_row_fields.inc.
This seems to solve the error for me in all cases. I plan to commit this to dev soon.

  • vegansupreme committed 372be29 on 7.x-1.x authored by asghar
    Issue #2563263 by vegansupreme, asghar: AJAX Error: The response failed...
vegansupreme’s picture

Status: Needs work » Fixed

Patch pushed. Maybe we should consider a stable release update with this fix and the last few dev fixes.

joshua.howell’s picture

patch in comment #21 works for me also.

killua99’s picture

Great job @vegansupreme! ;D

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mrmiso’s picture

This didn't work for me on i18n site. The path isn't build correctly as it is missing language prefix. I changed from
$GLOBALS['base_url'] . '/' . current_path()
to
$GLOBALS['base_root'] . request_uri().

Not sure if this is 100% correct solution but it works for me.

Also if I used FIX commented in Related issues in Views module it also worked correctly.