Steps to reproduce:

  1. enable the Locale module
  2. add a language in the language settings page
  3. enable the URL detection method in the language detection and selection tab
  4. enable the language switcher block
  5. change language using the language switcher
  6. 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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jpmckinney’s picture

Status: Needs work » Active
FileSize
2.15 KB

overlay-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:

$original_path = $path = '';
$options = array('external' => FALSE, 'prefix' => '');
drupal_alter('url_outbound', $path, $options, $original_path);
return $options['prefix'];

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.

jpmckinney’s picture

Status: Active » Needs work
jpmckinney’s picture

FileSize
2.17 KB

Fix my patch to avoid a warning about index: prefix not being set.

jpmckinney’s picture

FileSize
1.82 KB

Must it be a git diff for the test bot to run it?

casey’s picture

Status: Active » Needs review
plach’s picture

Status: Needs review » Needs work
+++ modules/overlay/overlay.module
@@ -470,6 +470,10 @@ function overlay_overlay_parent_initialize() {
+  $original_path = $path = '';
+  $options = array('external' => FALSE, 'prefix' => '');
+  drupal_alter('url_outbound', $path, $options, $original_path);
+  drupal_add_js(array('overlay' => array('prefix' => $options['prefix'])), 'setting');

This should work:

<?php
global $language_url;
drupal_add_js(array('overlay' => array('prefix' => $language_url->prefix)), 'setting');
?>

I'd definitely go for Drupal.settings.pathPrefix.

Powered by Dreditor.

jpmckinney’s picture

$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.

plach’s picture

You're right about $language_url: I did not consider the possible other hook_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 into bootstrap.inc.

+++ modules/overlay/overlay.module
@@ -470,6 +470,10 @@ function overlay_overlay_parent_initialize() {
+  $original_path = $path = '';

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.

jpmckinney’s picture

FileSize
1.82 KB

Re-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.

jpmckinney’s picture

FileSize
1.85 KB

Actually, $original_path will be passed by reference:

Fatal error: Cannot pass parameter 4 by reference in /var/www/drupal/seven/modules/overlay/overlay.module on line 475
Berdir’s picture

Status: Needs work » Needs review

Just wondering, is this needs work for a reason?

Setting to needs review for now... :)

jpmckinney’s picture

I 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.

plach’s picture

@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 with Drupal.settings.basePath.

jpmckinney’s picture

FileSize
4.34 KB

I added drupal_get_path_prefix() and I set Drupal.settings.pathPrefix (and I added similar tests to those for basePath).

Status: Needs review » Needs work

The last submitted patch, 759844-14.patch, failed testing.

jpmckinney’s picture

Status: Needs work » Needs review
FileSize
5.06 KB

Correct tests.

plach’s picture

Status: Needs review » Reviewed & tested by the community

I ain't sure we can add that API function, but aside from that the patch looks good and fixes the issue.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

chx 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.

chx’s picture

function drupal_get_path_prefix() {
  $prefix = &drupal_static(__FUNCTION__);
  if (!isset($prefix)) {
    url('', array('prefix' => &$prefix));
  }
  return $prefix;
}

wouldnt this work with a bit of comments, of course...?

jpmckinney’s picture

Status: Needs work » Needs review
FileSize
4.9 KB

New patch with chx's suggestion. Running test on my machine was taking too long.

jpmckinney’s picture

FileSize
5.13 KB

Tests passed locally. Added comments.

jpmckinney’s picture

FileSize
5.05 KB

Modified comments.

plach’s picture

Status: Needs review » Reviewed & tested by the community

looks better :)

sorry for missing the double drupal_alter() issue...

plach’s picture

Status: Reviewed & tested by the community » Needs work

I was too fast, the latest patch does not work for me: I never get an overlay. Debugging it right now.

plach’s picture

Status: Needs work » Needs review
FileSize
5.73 KB

The 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().

Remon’s picture

Status: Needs review » Reviewed & tested by the community

I followed the instructions aforementioned in issue's details, applied latest patch on today's drupal 7.x-dev and it works :).

Dries’s picture

Status: Reviewed & tested by the community » Needs work
+++ includes/common.inc	23 Apr 2010 23:59:06 -0000
@@ -2525,6 +2525,23 @@ function drupal_get_path($type, $name) {
+    // url() generates the prefix using hook_url_outbound_alter(). Instead of
+    // running the alter hook again here, extract the prefix from url().
+    url('', array('prefix' => &$prefix));
+    $prefix = empty($prefix) ? '' : $prefix;

This 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.

+++ includes/common.inc	23 Apr 2010 23:59:06 -0000
@@ -3549,6 +3566,7 @@ function drupal_add_js($data = NULL, $op
             array('basePath' => base_path()),
+            array('pathPrefix' => drupal_get_path_prefix()),

My only reservation is that the API is not consistent with base_path().

jpmckinney’s picture

@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().

catch’s picture

Priority: Critical » Normal

Downgrading from critical, the overlay not popping up on these paths doesn't render the site unusable, it just renders the overlay unusable.

plach’s picture

@catch:

Do you really mean it's ok to release Drupal 7 with a major UI functionality not working for multilingual sites?

catch’s picture

If 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?

plach’s picture

If this was the last critical bug against Drupal 7, and no viable patch, then I don't think it should block release, no.

Well, 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):

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.

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.

catch’s picture

I'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.

casey’s picture

@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.

plach’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
5.54 KB

As 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.

plach’s picture

Status: Needs work » Needs review
jpmckinney’s picture

Status: Needs review » Reviewed & tested by the community

I am pleased that my patch from #22 has more or less made it in :) Thanks for the reviews, plach!

marcingy’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

Changing to major as per tag.

MustangGB’s picture

Tag update

ksenzee’s picture

Simple reroll. The url() hack is a bit clever, but I agree it's the best option at this point in the cycle.

ksenzee’s picture

Re-reroll (local workspace was out of date).

aspilicious’s picture

Still applies

Jeff Burnz’s picture

Jeff Burnz’s picture

#41 fixes the problem, I can now load the Overlay when using path prefix.

mgifford’s picture

This 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.

bforchhammer’s picture

Possibly 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.

plach’s picture

I 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.

bforchhammer’s picture

I 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

Damien Tournoud’s picture

Status: Reviewed & tested by the community » Needs work

This 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.

ksenzee’s picture

Status: Needs work » Reviewed & tested by the community

Agreed 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.

sun’s picture

Status: Reviewed & tested by the community » Needs work
+++ includes/common.inc
@@ -3653,10 +3653,15 @@ function drupal_add_js($data = NULL, $options = NULL) {
+      // url() generates the prefix using hook_url_outbound_alter(). Instead of
+      // running the drupal_alter('url_outbound') again here, extract the prefix
+      // from url().
+      url('', array('prefix' => &$prefix));

This 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.

plach’s picture

This is an very intelligent solution attempt, I must say.

Yeah, a small masterpiece by chx :)

fleetcommand’s picture

Subscribing :)

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.

plach’s picture

Issue tags: +Needs committer feedback

Overlay (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.

plach’s picture

Title: Overlay does not work with path language prefixes enabled » Overlay does not work with prefixed URL paths

retitling

plach’s picture

Priority: Major » Critical
Issue tags: -Needs committer feedback

Ok, it seems I just have to push this to critical.

chx’s picture

Priority: Critical » Major

http://drupal.org/node/974066

If it can be fixed after RC1, or even at 7.2, it's not critical. Even if it's a really, really bad bug.

plach, seriously, I came up with this solution? shame on me.

dixon_’s picture

Status: Needs work » Needs review
FileSize
4.12 KB

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

plach’s picture

@dixon_:

Did you take into account #51?

Status: Needs review » Needs work

The last submitted patch, 759844-58-overlay-path-prefix.patch, failed testing.

dixon_’s picture

Status: Needs work » Needs review
FileSize
4.11 KB

@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.

dixon_’s picture

Status: Needs review » Needs work

Edit: I'll look into why the patch didn't apply. Could it be because I rolled it from the Git repo?

plach’s picture

Yes, try to roll the patch using cvs diff -up.

dixon_’s picture

Status: Needs review » Needs work
FileSize
4.09 KB

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.

dixon_’s picture

Status: Needs work » Needs review
Jeff Burnz’s picture

Status: Needs work » Needs review
fabsor’s picture

The patch works as intended. Here is another reroll.

ksenzee’s picture

Status: Needs review » Reviewed & tested by the community

#51 is D8 only. This, er, clever workaround is the best solution possible in D7. It needs to go in.

anavarre’s picture

Subscribing

mansspams’s picture

Subscribing

fjen’s picture

Subscribe

rfay’s picture

Version: 7.x-dev » 8.x-dev
Status: Reviewed & tested by the community » Needs review

D8 first. Let's get these fixed on D8 and into D7.

jpmckinney’s picture

Version: 8.x-dev » 7.x-dev
Status: Needs review » Reviewed & tested by the community

Arg, 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.

rfay’s picture

Version: 7.x-dev » 8.x-dev
Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs backport to D7

Very 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.

rfay’s picture

Oh 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.

ksenzee’s picture

Status: Needs review » Reviewed & tested by the community

The 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.

David_Rothstein’s picture

Agreed, 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...

pillarsdotnet’s picture

+1

catch’s picture

Yep, 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.

minff’s picture

+1

Tor Arne Thune’s picture

Being a victim of this issue, I fully support this patch. Hoping for it to get into 7.1.

pillarsdotnet’s picture

Gratuitous re-roll using git format-patch. No other changes. Still applies cleanly to both 7.x and 8.x, but made separate patches anyway.

jm.federico’s picture

PLEASE commit, this is sooo needed!

Dries’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/includes/common.inc
@@ -3951,10 +3951,15 @@ function drupal_add_js($data = NULL, $options = NULL) {
+      // url() generates the prefix using hook_url_outbound_alter(). Instead of
+      // running the hook_url_outbound_alter() again here, extract the prefix
+      // from url().
+      url('', array('prefix' => &$prefix));
       $javascript = array(

I wonder if this is the best approach for D8. Feels like we could benefit from a cleaner API to determine the prefix? Any thoughts?

sun’s picture

Status: Needs work » Reviewed & tested by the community

Quoting some stupid jerk from #51:

This is a very intelligent solution attempt, I must say. And I've seen a lot.

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.

Gábor Hojtsy’s picture

Agreed 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.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

I 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.

Status: Fixed » Closed (fixed)

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

Nor4a’s picture

FileSize
85.13 KB

I 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.

Nor4a’s picture

Version: 8.x-dev » 7.x-dev
Status: Closed (fixed) » Needs work

Forgot to change the status... sorry

xjm’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs work » Closed (fixed)

@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.

vidorado’s picture

This 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!

Drupal.overlay.isAdminLink = function (url) {
  ...
  var regExpPrefix = '^([a-z]{2}/)?(';
  ...
};

Hope that helps!

c960657’s picture