To reproduce this bug goto /messages and use one of the AJAX actions like "Mark as read"/"Mark as unread". Then try to sort the messages.

The soring is broken because the links get rewirtten to point to /system/ajax

Example URL for "Subject" link:
/system/ajax?destination=messages/list&sort=asc&order=Subject

Some users might search for this issue with the generated PHP error:

Notice: Undefined index: form_build_id in ajax_get_form() (line 312 of server/path/to/drupal/includes/ajax.inc).
CommentFileSizeAuthor
#8 fix_ajax_links.patch1.05 KBBerdir
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

This is nasty, nice catch.

This however sounds like a core issue to me and we can probably not solve it in a clean way.

Maybe if sorting could be done through AJAX as well, but I have no clue if that is possible.

derjochenmeyer’s picture

How does the AJAX functionality get added for the actions and the delete button? Is this not something privatemsg is doing?

Berdir’s picture

The request is sent with AJAX, the action is done and the whole table is rebuild and then replaced. But the problem is that when the table is rebuilt, the current URL ($_GET['q']) is system/ajax. And all links which point to the current page, especially those created by theme_table(), which does create the sorting links.

So we are really just glueing the different parts together which cause this error.

I need to talk to some of of the AJAX people what to do here.

derjochenmeyer’s picture

Its not even limited to the sorting. If you perform an action "Mark as read"/"Mark as unread"/"Delete" and use the "The previous action can be undone." link the "undo" works, but the destination is set to "system/ajax".

For reference the sorting URL is set in the core function tablesort_header (includes/tablesort.inc, line 169) the undo link ist build in function privatemsg_operation_execute (privatemsg.module, line 2118).

Berdir’s picture

Yes, it affects everything that is built durin the AJAX request, although I thought we had a workaround for the undo link.

Berdir’s picture

Looks like can fix it with a simple hack...

(18:39:31) merlinofchaos: You'll probalby need to set $_GET['q'] to the 'right' path.

Will work on a patch soon.

Berdir’s picture

Status: Active » Fixed

Please try the attached patch.

Berdir’s picture

Status: Fixed » Needs review
FileSize
1.05 KB

Wrong status and forgot file.

derjochenmeyer’s picture

Status: Needs review » Needs work

Thanks for the patch. The patch fixes the originally reported bug => fixes sorting.

But it does NOT fix the undo-link-bug reported in #4

Berdir’s picture

Status: Needs work » Postponed (maintainer needs more info)

I can not reproduce the undo bug, this has already been fixed a while ago with a very similiar hack. Are you sure that you are using the most recent version of Privatemsg-7.x-1.x (aka, newer than 7.x-1.0) ?

derjochenmeyer’s picture

Status: Postponed (maintainer needs more info) » Needs work
  1. I downloaded the latest dev (via: drush dl privatemsg --dev), ran update.php, cleared all caches
  2. Applied the patch provided in #8
  3. Went to /messages
  4. Checked a read message and chose "Mark as unread" from the "Actions..." dropdown
  5. The link in the generated status-message "The previous action can be undone." points to /messages/undo/action?destination=system/ajax which points (obviously) to a blank page.
BenK’s picture

For me, the patch also fixes the originally reported sorting bug.

As for the undo-link-bug, I don't have that problem at all. Undo links work for me both with and without the patch. The link is being sent to the proper place.

I did notice one other small issue, however: After you use the "Mark as read/unread" action, the "check all" checkbox is missing on the subsequent screen.

--Ben

Berdir’s picture

Berdir’s picture

Status: Needs work » Needs review

Setting back to needs review since we can't reproduce the undo but and the patch fixes the reported sorting issue.

We can still try to figure out why it doesn't work for @derjochenmeyer after this patch has been commited.

Berdir’s picture

Status: Needs review » Postponed (maintainer needs more info)

Commited the patch, thanks for reporting and testing.

Setting this back to postponed ( maintainer needs more info) as neither I nor BenK were able to reproduce your issue.

I'm not sure how reliable the drush --dev switch, can you try to specific explicitly privatemsg-7.x-1.x-dev? Or do a CVS checkout...

Berdir’s picture

Status: Postponed (maintainer needs more info) » Fixed

Closing this issue as there has been no response in multiple weeks.

Status: Fixed » Closed (fixed)

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

nguyentran’s picture

Hello,

I have the same problem when I add ajax paging for my inline form edit by ajax, and the patch work for me, Thank you so much. Especial thank to Berdir with your explaination.

geoandri’s picture

I have the same problem but i am a newbie in drupal.
Can you help me apply the patch?
Where do i have to execute the patch commands?

thank you

Status: Closed (fixed) » Needs review

imtoantran queued 8: fix_ajax_links.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 8: fix_ajax_links.patch, failed testing.

Berdir’s picture

Issue summary: View changes
Status: Needs work » Closed (fixed)