Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Steps to reproduce:
- enable the Locale module
- add a language in the language settings page
- enable the URL detection method in the language detection and selection tab
- enable the language switcher block
- change language using the language switcher
- click on any administration link in the toolbar
Probably the path prefix is not taken into account and so an administrative path is not recognized as such.
Comment | File | Size | Author |
---|---|---|---|
#89 | BrokenOverlayLangPrefix.png | 85.13 KB | Nor4a |
#82 | overlay-language_prefix-759844-82.patch | 4.8 KB | pillarsdotnet |
#82 | overlay-language_prefix-759844-82-d7.patch | 4.8 KB | pillarsdotnet |
#67 | overlay-path-prefix-759844-67.patch | 4.53 KB | fabsor |
#64 | 759844-64-overlay-path-prefix.patch | 4.09 KB | dixon_ |
Comments
Comment #1
jpmckinney CreditAttribution: jpmckinney commentedoverlay-parent.js does not take into account the fact that the URL may have a prefix.
There seems to be no API to get the current Drupal URL prefix. The only (ugly) way I know to do it reliably is:
Ideally, a prefix would be set at Drupal.settings.prefix, just like Drupal.settings.basePath.
In this patch, I store the prefix in Drupal.settings.overlay.prefix, so that I can at least show how this bug might be fixed.
Comment #2
jpmckinney CreditAttribution: jpmckinney commentedComment #3
jpmckinney CreditAttribution: jpmckinney commentedFix my patch to avoid a warning about index: prefix not being set.
Comment #4
jpmckinney CreditAttribution: jpmckinney commentedMust it be a git diff for the test bot to run it?
Comment #5
casey CreditAttribution: casey commentedComment #6
plachThis should work:
I'd definitely go for
Drupal.settings.pathPrefix
.Powered by Dreditor.
Comment #7
jpmckinney CreditAttribution: jpmckinney commented$language_url->prefix is only equal to the actual prefix if:
(1) The URL detection method in the language detection and selection tab is selected.
(2) No hook_url_outbound_alter (besides locale_url_outbound_alter) modifies the prefix.
So my original proposal still seems to be the only way to reliably and robustly determine the prefix.
Drupal.settings.pathPrefix should be set once we settle how best to determine the prefix.
Comment #8
plachYou're right about
$language_url
: I did not consider the possible otherhook_url_outbound_alter()
implementations. I cannot think of a cleaner way to determine the URL prefix without moving http://api.drupal.org/api/function/language_url_split_prefix/7 intobootstrap.inc
.If I recall well to improve readability we don't use this syntax. Anyway the
$original_path
parameter does not need to be a variable as it's passed by value, so we might just pass an empty string and avoid the nested initialization.However, I tested the patch and seems to work well but would it be possible to fix tests too?
Powered by Dreditor.
Comment #9
jpmckinney CreditAttribution: jpmckinney commentedRe-rolled with above suggestions. AFAIK, there are no tests for overlay, and I don't have the Drupal JS test-fu to start.
I don't think language_url_split_prefix is all we need to determine the URL prefix, because any module can modify the prefix. language_url_split_prefix will only work if only the locale module sets a prefix.
Comment #10
jpmckinney CreditAttribution: jpmckinney commentedActually, $original_path will be passed by reference:
Comment #11
BerdirJust wondering, is this needs work for a reason?
Setting to needs review for now... :)
Comment #12
jpmckinney CreditAttribution: jpmckinney commentedI only left it as "needs work" because I think there should be a better way to get the path prefix: my method seems a bit ugly.
Comment #13
plach@jpmckinney:
Originally path prefixes were introduced having only language in mind (see http://api.drupal.org/api/function/url/6 and http://api.drupal.org/api/function/language_url_rewrite/6). In D7 URL rewriting has been generalized but it seems that the path prefix is still strictly tied to language, at least according to the documentation (http://api.drupal.org/api/function/url/7), hence the correct API function to obtain the current path prefix should be http://api.drupal.org/api/function/language_url_split_prefix/7.
However I agree that nothing prevents modules from adding language-unrelated prefixes, so the above method won't work in those cases.
As I said, honestly I cannot imagine a better (less ugly, if you prefer :) method than yours not involving some kind of API change, which at this stage is rather unlikely to happen.
Btw I think we should really set
Drupal.settings.pathPrefix
together withDrupal.settings.basePath
.Comment #14
jpmckinney CreditAttribution: jpmckinney commentedI added drupal_get_path_prefix() and I set Drupal.settings.pathPrefix (and I added similar tests to those for basePath).
Comment #16
jpmckinney CreditAttribution: jpmckinney commentedCorrect tests.
Comment #17
plachI ain't sure we can add that API function, but aside from that the patch looks good and fixes the issue.
Comment #18
webchickchx says this can't go in as-is, because we're calling an alter hook from more than one place. He's going to brainstorm with jpmckinney on another solution.
Comment #19
chx CreditAttribution: chx commentedwouldnt this work with a bit of comments, of course...?
Comment #20
jpmckinney CreditAttribution: jpmckinney commentedNew patch with chx's suggestion. Running test on my machine was taking too long.
Comment #21
jpmckinney CreditAttribution: jpmckinney commentedTests passed locally. Added comments.
Comment #22
jpmckinney CreditAttribution: jpmckinney commentedModified comments.
Comment #23
plachlooks better :)
sorry for missing the double
drupal_alter()
issue...Comment #24
plachI was too fast, the latest patch does not work for me: I never get an overlay. Debugging it right now.
Comment #25
plachThe problem was with empty-prefixed paths which got
Drupal.settings.pathPrefix = 'null'
. This one should be ok.Probably we need some tests for
drupal_get_path_prefix()
.Comment #26
Remon CreditAttribution: Remon commentedI followed the instructions aforementioned in issue's details, applied latest patch on today's drupal 7.x-dev and it works :).
Comment #27
Dries CreditAttribution: Dries commentedThis seems to be a bit of a hack to me. The better solution would probably to implement drupal_get_path_prefix() properly, and then to re-use it in url() or something. Either way, if we introduce a drupal_get_path_prefix() it should probably be used by the rest of Drupal.
My only reservation is that the API is not consistent with base_path().
Comment #28
jpmckinney CreditAttribution: jpmckinney commented@Dries: should the function be named path_prefix() to be consistent with base_path()?
It is a bit of a hack, but every alternative explored thus far was a bigger hack. url() gets the prefix in its $options array, and then gives modules an opportunity to alter it by calling drupal_alter('url_outbound', $path, $options, $original_path). Code in that alter could change the prefix based on the $path and on the contents of $options. Really, drupal_get_path_prefix() is a bit of a lie, as it really only gets the prefix for a URL whose path is "" and which has no other options.
Perhaps we should not add drupal_get_path_prefix(), and just do the prefix extraction dance in drupal_add_js().
Comment #29
catchDowngrading from critical, the overlay not popping up on these paths doesn't render the site unusable, it just renders the overlay unusable.
Comment #30
plach@catch:
Do you really mean it's ok to release Drupal 7 with a major UI functionality not working for multilingual sites?
Comment #31
catchIf this was the last critical bug against Drupal 7, and no viable patch, then I don't think it should block release, no.
Frankly I'm fed up that 1/10 critical issues are due to overlay module, for something which is a completely optional admin-only feature that is to say the least controversial, and that percentage appears to be going up as the number of critical issues overall reduces.
There are various issues with hook_url_outbound_alter() and hook_url_inbound_alter() - notably the inability to tell what's happened to paths without running the hooks again in most cases too. I haven't re-read this entire issue, but could we pass an additional argument into those hooks for "prefix" and let modules implementing the hook update that - that'd then mean we could access it from drupal_get_path_prefix() or similar too no?
Comment #32
plachWell, in this case what's holding the patch to be committed is we don't have a solution for the problem you correctly identified below (which is not an overlay-specific issue):
We can downgrade this to normal (and quickfix it) but we have still the hook_url_outbound_alter()/hook_url_inbound_alter() issues which feel rather critical.
Comment #33
catchI'm fine with a critical issue dealing with the inability to know what hook_url_*_alter() are doing without invoking them again, and if necessary postponing this on that. I was looking at the D7 port of globalredirect recently, and that's pretty much broken if anything implements hook_url_inbound_alter() too - not to mention it has to re-invoke the equivalent hooks in D6 too.
Comment #34
casey CreditAttribution: casey commented@plach could you do a reroll but without drupal_get_path_prefix() as @jpmckinney suggests in #28? That will get the patch to be committed much faster.
Comment #35
plachAs proposed in #28 and #34 the attached patch removes the
drupal_get_path_prefix()
API function in favor of a dedicated (critical) issue.Adding this issue to the major queue, anyway.
Comment #36
plachRelated issue: #832862: hook_url_inbound_alter breaks the module.
Comment #37
jpmckinney CreditAttribution: jpmckinney commentedI am pleased that my patch from #22 has more or less made it in :) Thanks for the reviews, plach!
Comment #38
marcingy CreditAttribution: marcingy commentedChanging to major as per tag.
Comment #39
MustangGB CreditAttribution: MustangGB commentedTag update
Comment #40
ksenzeeSimple reroll. The url() hack is a bit clever, but I agree it's the best option at this point in the cycle.
Comment #41
ksenzeeRe-reroll (local workspace was out of date).
Comment #42
aspilicious CreditAttribution: aspilicious commentedStill applies
Comment #43
Jeff Burnz CreditAttribution: Jeff Burnz commented#41: 759844-41-overlay-path-prefix.patch queued for re-testing.
Comment #44
Jeff Burnz CreditAttribution: Jeff Burnz commented#41 fixes the problem, I can now load the Overlay when using path prefix.
Comment #45
mgiffordThis patch worked fine for me in Seven, Garland & Bartik. Without it there's no access to Overlay for the arabic language I was testing it with.
If Overlay is going to be in core (especially default core) it really needs to be able to work in RTL.
Comment #46
bforchhammer CreditAttribution: bforchhammer commentedPossibly a slightly different issue but the overlay also does not seem to work with language domains...
Same steps to reproduce, but use language domains on the language settings page, and use "domain" instead of "prefix" on the settings for URL detection.
Comment #47
plachI cannot reproduce #46 both with the patch applied and without. Can we open a separate issue to track it down more easily?
Instead I confirm that #41 still fixes the issue.
Comment #48
bforchhammer CreditAttribution: bforchhammer commentedI can also confirm that #41 works as intended (it makes it possible to load the overlay when using language prefixes).
What I meant in #46 is actually a different issue: language switching does not work at all when the overlay is active; not with language domains nor with prefixes. As per plach's suggestion I have opened a new issue for that: #918738: Overlay does not allow language switching
Comment #49
Damien Tournoud CreditAttribution: Damien Tournoud commentedThis is really ugly. The overlay has a really poor handling of URLs, and will completely break as soon as URL aliases are used or URL rewriting takes place.
We need to get rid of
Drupal.overlay.isAdminLink
completely. The client side is definitely not the place to check internal URLs.Comment #50
ksenzeeAgreed that the client side is a bad place to check internal URLs. Nobody has ever been happy about it. However: a) it's not as dire as you make out, since aliasing admin URLs isn't that common, and b) nobody has been able to come up with a better option. It's not a trivial undertaking. And until we have a patch to replace it, we need this incremental fix.
If you have ideas on replacing it, though, I'd love to see them in a separate issue.
Comment #51
sunThis is an very intelligent solution attempt, I must say. And I've seen a lot.
Technically, this issue is a duplicate of #481560: Provide proper AJAX URL resp. base path depending on context
What you can read over there, and what is not covered by this patch, is a different $base_url, which can also be altered via hook_url_outbound_alter().
Please review aforementioned issue prior to marking this one RTBC again.
That said, the comment should definitely state hook_url_outbound_alter() instead of a PHP construct.
Powered by Dreditor.
Comment #52
plachYeah, a small masterpiece by chx :)
Comment #53
fleetcommand CreditAttribution: fleetcommand commentedSubscribing :)
I was looking through the bug database to see why my overlay does not work in current beta... As soon as I saw the title of this bugreport, I realized what causes it.
Comment #54
plachOverlay (the whole system!) is not working for multilingual sites (or any others) using url path prefixes. As per the beta-3 announcement I'd like core committers to evaluate this issue, as it might be upgraded to critical again.
Comment #55
plachretitling
Comment #56
plachOk, it seems I just have to push this to critical.
Comment #57
chx CreditAttribution: chx commentedhttp://drupal.org/node/974066
plach, seriously, I came up with this solution? shame on me.
Comment #58
dixon_Here is a reroll of the patch from #41. It was quite outdated as one could expect. All the AJAX tests seems to have been rewritten since July ;)
So, hopefully I squeezed the tests in correctly here. Lets see what the bot says.
/dixon_ from the Dev Days code sprint in Brussels
Comment #59
plach@dixon_:
Did you take into account #51?
Comment #61
dixon_@plach:
Actually I missed that. But in general #481560: Provide proper AJAX URL resp. base path depending on context was postponed to 8.x, so I don't think we can do much about it. Or maybe I got something wrong?
But I've now fixed the comment that sun mentioned.
Comment #62
dixon_Edit: I'll look into why the patch didn't apply. Could it be because I rolled it from the Git repo?
Comment #63
plachYes, try to roll the patch using
cvs diff -up
.Comment #64
dixon_It should work with Git patches, shouldn't it? The Git repository is fully in sync with CVS. I've now done minor changes to the diff format, so it is the same as in #41. Should work?
Edit: I found out that you need to roll the patch with
git diff --no-prefix
.Comment #65
dixon_Comment #66
Jeff Burnz CreditAttribution: Jeff Burnz commented#64: 759844-64-overlay-path-prefix.patch queued for re-testing.
Comment #67
fabsor CreditAttribution: fabsor commentedThe patch works as intended. Here is another reroll.
Comment #68
ksenzee#51 is D8 only. This, er, clever workaround is the best solution possible in D7. It needs to go in.
Comment #69
anavarreSubscribing
Comment #70
mansspams CreditAttribution: mansspams commentedSubscribing
Comment #71
fjen CreditAttribution: fjen commentedSubscribe
Comment #72
rfayD8 first. Let's get these fixed on D8 and into D7.
Comment #73
jpmckinney CreditAttribution: jpmckinney commentedArg, but it's RTBC in 7.x! Why can't we commit it there first? It's basically been re-rolled and RTBC for a year, with only two people who haven't been following it closely chiming it to say that the patch is wrong, and then having other people explain that it's the best solution for 7.x. Read the OP - this is a major bug. You can't have a multilingual site that uses path language prefixes without breaking the overlay. That's major.
Anyway, it's not "needs review" for 8.x, because there is no 8.x patch. For 8.x, we should come up with an alternative patch that makes the 7.x workaround unnecessary.
Comment #74
rfayVery sad. It's always been the policy to do it first in the higher revision. It's just that we weren't really ready I guess to open D8. Just push it through into D8 and then it will pop back here and webchick will commit it easily.
Comment #75
rfayOh I should mention: The reason that this has been languishing in the RTBC queue is that webchick just isn't committing patches that haven't been applied to D8. So you can move it back to the D7 RTBC queue if you want, but I don't think it will do you any good.
Comment #76
ksenzeeThe problem is that this patch isn't what anyone wants for D8. This is one of those dangerous situations where we need a fix for D8 so we don't get regressions, but we don't want to commit a hack to D8, so we run the risk of a 300-comment D8 issue about the right fix, while the correct stopgap for D7 sits around not being committed.
To keep that from happening, I submit that this should go into D8 as is and get backported to D7, and then we can figure out the correct fix for D8 at our leisure. The patch still applies to D8, and I've tested that it still works, so back to RTBC.
Comment #77
David_Rothstein CreditAttribution: David_Rothstein commentedAgreed, if it's good enough for D7, then by definition it's good enough for D8 (even if not ideal for D8).
And if you want to make that official policy, #1050616: Figure out backport workflow from Drupal 8 to Drupal 7 is the place to comment :) I think this issue is actually a prime example of why we need that...
Comment #78
pillarsdotnet CreditAttribution: pillarsdotnet commented+1
Comment #79
catchYep, couldn't agree more with #76/77. This is precisely why we need to get things into 8.x first - if we /only/ committed this to D7 and waited for the proper fix in D8, that might never come.
Comment #80
minff CreditAttribution: minff commented+1
Comment #81
Tor Arne Thune CreditAttribution: Tor Arne Thune commentedBeing a victim of this issue, I fully support this patch. Hoping for it to get into 7.1.
Comment #82
pillarsdotnet CreditAttribution: pillarsdotnet commentedGratuitous re-roll using git format-patch. No other changes. Still applies cleanly to both 7.x and 8.x, but made separate patches anyway.
Comment #83
jm.federico CreditAttribution: jm.federico commentedPLEASE commit, this is sooo needed!
Comment #84
Dries CreditAttribution: Dries commentedI wonder if this is the best approach for D8. Feels like we could benefit from a cleaner API to determine the prefix? Any thoughts?
Comment #85
sunQuoting some stupid jerk from #51:
This is the "best" approach at this point in time. However, please feel free to step through the commit logs of admin_menu from the past 2 years to learn about 3-5 different incarnations of this approach and attempts to solve it differently, which all failed in one way or another. The particular attempt of this patch is not excluded from that, but comparing it to approaches in history, it's at least more solid than all known attempts to date.
The ultimate but yet unknown answer will have to be found in #481560: Provide proper AJAX URL resp. base path depending on context. However, given the complexity and amount of unknown factors that are outlined in detail on aforementioned issue, my prediction on that issue is, that we won't see a "proper" answer for the next 3 years -- if there can be a proper answer at all.
Comment #86
Gábor HojtsyAgreed with @sun. Theoretically the url prefix can be different per path in fact, but I've not seen a module yet that would do it (except maybe some crazy stuff I did back in 2005 or so :). So the main problem is indeed that we need to work with one prefix that JS could apply to all kinds of paths then. I think this patch at least makes overlay work on multilingual sites, where it is otherwise entirely broken, so let's get this one in. Then we can lament on having URL prefix in a page context for Drupal 8 and also on how to figure out the right prefix for all kinds of paths. I think this should go in now.
Comment #87
Dries CreditAttribution: Dries commentedI did some more digging and I fully understand the complexity now -- thanks for the clarification/pointers sun and gabor.
I've committed this patch to 8.x and 7.x. One less major bug.
Comment #89
Nor4a CreditAttribution: Nor4a commentedI just have upgraded to Drupal 7.12 and the problem seams to be back...
I'm using the standard theme for admin pages and custom theme for non-admin pages.
I use the latest i18n (7.x-1.4) module to translate nodes.
I have 4 languages enabled. - default English
When I open the node translations tab where I can add the translations - only link which works in overlay is non-prefixed link. Other links opens without overlay. See attached image about what the links I'm talking about.
Comment #90
Nor4a CreditAttribution: Nor4a commentedForgot to change the status... sorry
Comment #91
xjm@Nor4a -- I'd suggest opening a new issue with steps to reproduce, as this particular issue has already been patched. I'd also suggest testing whether the issue is reproducible without i18n, and if not, probably file the issue against i18n.
Comment #92
vidorado CreditAttribution: vidorado commentedThis is a quick quick soluction, but it seems to work (no patch, no diff... just quick and dirty, haha).
In the file "/modules/overlay/overlay-parent.js" change the variable regExpPrefix to consider all two-letter prefixes followed by an admin path. This let's Overlay consider the admin links regardless the language they are in.
This makes i18n interface switching on node editing of translations in other languages different from the actual not to leave the overlay layer!
Hope that helps!
Comment #93
c960657 CreditAttribution: c960657 commentedFollow-up issue: #1431076: Overlay does not work with prefixed URL paths