Problem/Motivation
arg(0) returns 'fr' when two languages are enabled and Language Path Negotiation is enabled and then visiting 'fr/front'. It should return 'front'.
This confuses quite some modules, like the classes for html have the language prefix in, theme suggestions also contain the language prefix.
Proposed resolution
During LanguageNegotiationUrl::getLangcode we know the path prefix and then we can remove it
Remaining tasks
Review
User interface changes
-
API changes
-
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 2251061-17.patch | 4.5 KB | marthinal |
| #16 | 2251061-15.patch | 4.41 KB | marthinal |
| #16 | 2251061-15-only-test-should-fail.patch | 3.65 KB | marthinal |
| #14 | 2251061-14-only-test.patch | 3.65 KB | marthinal |
| #14 | interdiff-2251061-10-14.txt | 928 bytes | marthinal |
Comments
Comment #1
schnitzel commentedComment #2
schnitzel commentedComment #3
dawehnerThe actual bug is that code is using arg() but yeah things aren't simple ... see https://drupal.org/node/788900
arg() should maybe just switch to \Drupal::request()->attributes->get('system_path');
Comment #5
schnitzel commentedComment #6
schnitzel commentedComment #7
tetranz commentedI changed the file header to say Contains \Fully\Qualified\Namespace\And\NameOfTheClass instead of Definition of as per https://drupal.org/node/1354#file
Practicing my first patch :)
Comment #9
tetranz commentedI should have made the interdiff a .txt file. I will resubmit after the test completes.
Comment #10
tetranz commentedSame as above but interdiff.txt
File header changed to say Contains \Fully\Qualified\Namespace\And\NameOfTheClass instead of Definition of as per https://drupal.org/node/1354#file
Comment #11
yesct commentedComment #12
penyaskitoComment #13
gábor hojtsyLooks like the last test only patch does not fail? Hum.
Comment #14
marthinal commentedLooks the test is not applied as expected, let's take a look at this. Here a couple of changes.
Comment #16
marthinal commentedLet's try again.
Comment #17
schnitzel commentedoh thanks @marthinal, looks like the test was never run :)
btw, during working more on our site, I figured out that in some cases LanguageNegotiationUrl::getLangcode() can be called twice, like when a Module want's to load the current langcode. Which as far as I know should not happen, the langcode should be loaded via the request object, but anyway it happens :)
So if this happens there is too much removed from the current path.
This fixes this:
I can change the patch, but I guess you will be faster in it :)
Comment #18
marthinal commented@Schnitzel sure! done. Many thanks!
Comment #20
schnitzel commented@marthinal
Great, maybe we wanna update the tests as well, that we call
LanguageNegotiationUrl::getLangcode()twice, then we also have tested that :)Comment #21
yesct commentedHere's a diff of 15 and 17
Comment #22
marthinal commented18: 2251061-17.patch queued for re-testing.
Comment #24
marthinal commented18: 2251061-17.patch queued for re-testing.
Comment #25
gábor hojtsy#788900: Deprecate and remove usages of arg() (change notice at https://drupal.org/node/2274705) says arg() is deprecated. For the practicalities of this issue, _current_path() is already broken (which is suggested in place of arg() for taking path segments). So this may need to be repurposed to talk about _current_path().
Comment #26
marthinal commentedAbout _current_path().
So, I'm not sure if we should continue working on this using that function.
Comment #27
yesct commentedthat todo is #2237001: Remove no longer needed _current_path() fallback for early bootstrap
(according to #1183208-111: Remove variable_get('clean_url') and switch to index.php/path pattern for dirty URL support)
Comment #28
tstoecklerI think this patch needs to be updated per #2294093: Remove arg(). Or am I missing something?
Comment #29
gábor hojtsyThis looks to be obsolete to me? As explained in the change notice for #2294093: Remove arg() (https://www.drupal.org/node/2274705), you would use route matching. If you have a raw path somehow early in the request and need to match the route, you can use a PathProcessor to remove unwanted things. #1833010: Admin user language preference WSOD if ahead of path prefixes has a solution that now the admin language preference uses to do the same thing before the path itself is processed later on in the request, which you can use to process your path. That will remove any language prefix, resolve aliases, and any other path mangling the negotiators may have done.