Needs review
Project:
CTools Auto-modal
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Feb 2012 at 10:22 UTC
Updated:
10 Oct 2012 at 10:45 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #1
wojtha commentedInitial attempt to fix it.
If the menu callback is returning access denied or page not found in menu_execute_active_handler() the CTools Automodal menu callbacks are bypassed and standard Drupal error pages are returned via drupal_deliver_html_page() causing the AJAX errror.
I'm using hook_page_delivery_callback_alter() to detect it the request is AJAX request and I'm detecting if the current menu callback returns error or not. If so I'm returning special version of the error page and I give opportunity with hook_modal_error_alter() to other modules to react - change the error message or react with own customized AJAX commands on some paths.
Comment #2
wojtha commentedComment #3
marco commentedHi,
thank you for your patch.
I tested it and it worked, but it caused problems with quicktabs module. Every Ajax tab load caused a "An AJAX HTTP error occurred" alert to pop up (and the quicktab was not populated). Interestingly, "HTTP Result Code" was 200 and "StatusText" was OK.
I was able to fix this removing $callback = 'ajax_deliver'; in ctools_automodal_page_delivery_callback_alter(), but I'm not sure why you didn't leave $callback as "drupal_deliver_html_page" when you don't intercept the callback, so I don't know whether my fix has some side effects. Can you please shed some light on this?
Thanks
Marco
Comment #4
wojtha commentedYeah, I've also found that week ago. The "$callback = 'ajax_deliver';" does it wrong, but didnt have time to update the patch yet.
There is no side effects AFAIK, so remove it :-)
Comment #5
douggreen commentedUpdated patch removing $callback assignment and also fixing PHP warning caused by not imploding $path_parts in one code path.
Comment #6
j0rd commentedI have the same problem (updated)
Patch #5 doesn't work for me, I still get the large ajax alert error box.
Patch #1 does seem to work for me, I get the appropriate drupal_set_message() error in the alert box and only that.
Here's what I'm doing.
Assumptions:
Using user/login in the modal.
Steps:
1. Be an anonymous user.
2. Open two tabs.
3. Login (in the modal) with Tab#1 and wait until that process finishes.
4. Now try to do the same in Tab#2 and you'll get "Access Denied" 403 error because you're logged in, and that how it works in the user.module
5. Get a mega huge alertbox with patch #5, and reasonable one with patch #1.
I am also using loggintoboggan module, which has `function logintoboggan_page_alter()` which adds some drupal_set_messages(), which could be causing my additional problems.
Here's that code from logintobogan
UX Improvement: Close modal after error is closed.
After the javascript alert() box is closed, ideally we would close the modal as well. This seems to make sense for things like MENU_ACCESS_DENIED, MENU_SITE_OFFLINE, MENU_NOT_FOUND use cases, as the modal will just sit there and be blank.
Comment #7
dave reidShould this be filed against CTools modal functionality itself? I'm not sure why this is specific to CTools automodal.
Comment #8
antondavidsen commentedpatch #5 seems to give some warnings in relation to other modules. This was caused by features:
Warning: preg_match() expects parameter 2 to be string, array given in ctools_automodal_is_path_modal() (line 181 of ... ctools_automodal.module).
Comment #9
asimov6 commentedShouldn't the path given in menu_get_item($path) in function ctools_automodal_get_page_callback_error($path) not be the full path, i.e. including 'ajax' or 'nojs'.
I am getting page not found for all of the paths without the last bit (ajax,nojs)