Should we expect that in drupalSettings.path.pathPrefix we will have the language code, in case we have a multilingual installation with URL language detection enabled, and we are on a page with a language prefix URL?
If so, apparently we have currently an empty value (if I did not make mistakes :))
Comment | File | Size | Author |
---|---|---|---|
#20 | interdiff_14-20.txt | 1.1 KB | mondrake |
#20 | drupal-2146035-20.patch | 4.12 KB | mondrake |
#16 | drupal-2146035-14.patch | 4.05 KB | olli |
Comments
Comment #1
nod_Good question, I don't know :o
Comment #2
olli CreditAttribution: olli commentedComment #3
mondrakeConfirm that #2 solves the issue, the pathPrefix is now filled in in the context described by the OP.
However, I think it would make sense to adjust the Drupal.js url() function accordingly, so that UrlGenerator::generateFromPath() on the server side and Drupal.url() on the client side provide same behaviour:
Comment #4
olli CreditAttribution: olli commentedThis needs testing.
Comment #5
mondrakeLet's see testbot
Comment #6
dawehnerI wonder whether we also have to adapt the generateFromRoute function.
Comment #7
jessebeach CreditAttribution: jessebeach commentedPlease also consider any effect on Toolbar JS code that this change might produce. See #2218313: Toolbar subtree is broken if you use a different language..
Comment #8
mondrakeAs for manual testing, I tested patch in #4 with the contrib Pagerer module I am developing/maintaining.
Pagerer uses Drupal.url() to build dynamically pager links on the client-side. In fact, the OP is due to the fact that working on its conversion to D8, I came across the issue. It is visible on the page available at path
pagerer/example
, with the Pagerer example module installed. Pager links created on the server-side are correct, but those created dynamically (in slider/scrollpane/mini pager styles) do not bear the language prefix, hence paging to pages with default site language. The patch in #4 fixes the problem.Leaving to NR for any further testing.
Comment #9
olli CreditAttribution: olli commentedRe #6: How?
Re #7: With this code, toolbar links have the correct prefix:
1. Install standard + language
2. Add Dutch language
3. Goto /nl, expand "Reports", click "Status report"
You should be at /nl/admin/reports/status
Without this patch the js loads from /toolbar/subtrees/hash/nl, with this code it loads /nl/toolbar/subtrees/hash/nl.
Comment #10
mondrakeAs #4 with a test to check that drupalSettings.path.pathPrefix is filled in with the language code. Test only should fail, the other pass. Interdiff == test only. I doubt we can do testing on the js side as of now, but manual testing in #8 and #9 covers enough?
Comment #12
jessebeach CreditAttribution: jessebeach commentedWe had run the
$prefix
throughrawurlencode
, but the raw prefix is passed to configuration now. Did this just open an attack vector?Comment #13
olli CreditAttribution: olli commentedThis adapts generateFromRoute instead.
Comment #14
olli CreditAttribution: olli commented... with the change in drupal.js and an interdiff. (ignore #13)
Comment #15
olli CreditAttribution: olli commented14: drupal-2146035-14.patch queued for re-testing.
Comment #16
olli CreditAttribution: olli commentedReroll for psr-4.
Comment #18
mondrakeThis fixes OP, the issue reported in #8, has automated tests for the backend, and was manually tested on the frontend in #8 and #9. I tested manually again now and it still applies and works as expected. RTBC
Comment #19
chx CreditAttribution: chx commentedI only have one question -- do we really need a complete test for this? Isn't it possible to just add that assert ... somewhere?
Comment #20
mondrakeRe #19, moved that test code to the
setUp()
method. I tried to move it tocheckUrl()
but that does not seem to bring up drupalSettings. The other methods seem to have very specific scope so I have not touched. If we don't like this we still have #16.Comment #21
chx CreditAttribution: chx commentedLovely. Compared to #16 we are running an extra drupalGet at the cost of saving a Drupal install (there are two test methods). That's a big win as far as I am concerned. If the esteemed core committers disagree, well, #16 is good to go too.
Comment #22
alexpottLooks good - nice find.
Committed 22ca7bc and pushed to 8.x. Thanks!