I have the problem since update from 7.x-3.4 to 7.x-3.5.
This happens on following domain configuration:
There are 3 domains, one marked as default domain. All 3 domains use a different sub-theme, all sub-themes use the same parent theme. There is an administration theme set on all 3 domains, all set on the same pages, and all use the same admin theme.
Scenario: As a guest (or a user without corresponding permissions) trying to access administration pages which use an admin theme, I get a 403 rendered with a wrong theme.
More specific: I access the default domain site, trying to load an administration page without required permissions. The 403 page should render with the theme set for the current site, because I have no right to use the admin theme. Instead, an other theme from an other, non-default domain is being loaded.
There is no other module installed which affects theme manipulation on this process.
With previous version 7.x-3.4 this worked fine.
Marked as major because wrong theme loading breaks site's consistency.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 1858356-admin-theme.patch | 1.07 KB | agentrickard |
| #5 | 1858356-admin-theme.patch | 983 bytes | agentrickard |
| #4 | 1858356-admin-theme.patch | 993 bytes | agentrickard |
Comments
Comment #1
agentrickardRight. So let me see if I have this correct.
* 3 domains. Each has a specific theme and specific admin theme.
* User tries to access /admin. Gets 403 page.
* 403 page renders in the admin theme of the current site.
Is that last part correct? Or does it render in the admin theme of the default site?
Comment #2
agentrickardIn my test. The 403 returned the theme for the default domain, even though I was on a different domain.
Comment #3
agentrickardHere's the problem code, from domain_theme_custom_theme():
Let's try reversing those lines.
Comment #4
agentrickardThis should work.
Comment #5
agentrickardThe $_GET['q'] is not required.
Problem is, we've seen misbehavior using menu_get_item() here before, especially when AJAX is involved (as in Features admin).
Comment #6
mxh commentedAlthough you've already spotted the problem right, let me correct your assumption from #1:
* 3 domains. Each has a specific theme and the same admin theme set on the same pages.
* User tries to access /admin. Gets 403 page.
* 403 page renders in an non-admin theme which is not allocated to the current site. A wrong theme is being rendered on these pages.
Does menu_get_item() not work well with AJAX in general?
Comment #7
agentrickardRight. As I understand it, the 403 should not render in the admin theme. It should render in the assigned domain theme.
The problem with AJAX and menu_get_item() is that the second page request (the AJAX call) can reset the menu item and throw off the expected behavior. I have seen that with Features and Display Suite admin pages.
If the Features admin works with this code, then it should be ready to go.
Comment #8
agentrickardSo this causes Features to display in the wrong theme, due to the AJAX.
See #1718968: Domain Conf administrative theme <=> Domain Theme theme settings for where this code was introduced.
See #1419090: Domain theme, admin theme broken broken for certain paths in Features module for the Features issue.
Comment #9
mxh commentedYes.
This seems to become a difficult one. In my next free time, I will also look for a solution.
Comment #10
agentrickardIt is difficult, because of the execution order of the code and the frustrations of the menu system, we cannot check for menu access without invoking menu_get_item(), and invoking that function breaks certain admin paths.
I have not found a way to fix your issue without re-breaking #1419090: Domain theme, admin theme broken broken for certain paths in Features module or doing handstands to load the menu data without calling menu_get_item().
At this point in the call stack, even drupal_get_http_headers() returns empty, because headers haven't been set yet.
Comment #11
agentrickardStep away for a bit, and clarity appears ;-).
This would, at least, work for anon users.
Comment #12
mxh commentedYep, #11 works for me with anonymous users.
Now authenticated users without required permissions get the admin theme loaded, but they should get the same result as anonymous users.
I think the problem is now somewhere else, at a point where the admin theme is being set. Whatever I do in domain_theme_custom_theme(), even when I return a fixed string with a machine name of a theme, the admin theme is used when the user is authenticated.
Comment #13
agentrickardI don't follow point 3 above.
The issue is that we can't run a check for menu item access without breaking certain theme functions. That's what the old Features issue is about. The patch in #11 tries to fix that, and is perhaps correct. If you can view admin theme and the 403 is an admin page, using the admin theme seems appropriate.
There is also a permission for 'view administration pages', and we could check that instead.
Comment #14
agentrickardThe patch mimics what core does. If you can access the admin theme in core, your 403 is delivered in the admin theme.
Comment #15
mxh commentedOk I have tested with previous domain version 7.x-3.4 and it shows the same behavior now when #11 is used in 7.x-3.5, so for me this issue can be marked as fixed.
But I don't understand why an authenticated user without permission 'view the administration theme' can ever see a page rendered with admin theme, like at the moment 403 admin pages.
Anyway, thank you for the ultrafast support.
Comment #16
agentrickardAt the moment, it's because we don't check that access. This patch fixes that.
Comment #17
agentrickardCommitted!