- Issue created by @mkalkbrenner
- Status changed to Needs review
over 1 year ago 4:19pm 20 March 2023 - π©πͺGermany mkalkbrenner π©πͺ
The attached patch fixes the language switcher for our sites.
- Status changed to Postponed: needs info
over 1 year ago 6:20pm 20 March 2023 Yes I think this probably duplicates existing critical bug reports. Can you confirm?
- π¨π¦Canada joseph.olstad
Patch #4 works. I'm not sure if this is better than the other patch but it sure is a lot less lines of code and I like that!
- π¨π¦Canada joseph.olstad
Surprising that the core automated tests did not pick this up
- π¨π¦Canada joseph.olstad
patch #4 works for the wxt distribution, the patch from the other issue does not work for us.
- π¨π¦Canada joseph.olstad
add tests by @alex_pott from the related issue
π [regression] Language switcher block throws exception when no route is matched Fixed - Status changed to Needs review
over 1 year ago 8:02pm 20 March 2023 The last submitted patch, 11: 3349111-11.patch, failed testing. View results β
- Status changed to Postponed: needs info
over 1 year ago 9:36pm 20 March 2023 I don't think contributors should be trying to solve one problem in two issues.
- Status changed to Needs review
over 1 year ago 10:07pm 20 March 2023 - π¨π¦Canada joseph.olstad
Hi ciolefen, agreed, I'll move this change over to the other issue
- Status changed to Postponed: needs info
over 1 year ago 10:08pm 20 March 2023 - π¬π§United Kingdom alexpott πͺπΊπ
T
+++ b/core/modules/language/src/ConfigurableLanguageManager.php @@ -418,7 +418,7 @@ public function getLanguageSwitchLinks($type, Url $url) { try { - return $url instanceof Url && $url->access(); + return $url instanceof Url && $url->access(NULL, TRUE);
This part is incorrect. It breaks the security fix because now when $url->access() is forbidden it returns an object and this evaluates to TRUE. Thereby, this completely undoes the recent security fix. If this is "fixing" your site then it points to access not being set up quite the right way - or another issue. But this certainly is not the fix.
- Status changed to Closed: works as designed
over 1 year ago 9:05am 21 March 2023 - π¬π§United Kingdom alexpott πͺπΊπ
The contrib language switcher had the same security issue as core's and therefore needed to be updated - see #3349214: language switcher fix related to Core Security update. β
- Status changed to Active
over 1 year ago 9:16am 21 March 2023 - π©πͺGermany mkalkbrenner π©πͺ
I'm not aware that we use anything else but core here!
We simply use Drupal\language\Plugin\Block\LanguageBlock with the configuration I posted in the description.
And now the language switcher block is gone on ALL pages.
I don't see what should be wrong in our setup. Form my point of view there must be a bug in core. - π¬π§United Kingdom james.williams
We have a few very closely related issues about the regressions:
- π [regression] Core language switcher disappeared in Drupal 9.5.5 Closed: works as designed (this ticket) - this is perhaps the one with the broadest scope, but as alexpott has said, the patches here so far reopen the security vulnerability
- π [regression] Language switcher block throws exception when no route is matched Fixed - this is where the best progress seems to have been made so far, though the initial ticket scope appears quite limited, focussing around an exception
- π [regression] Inaccessible language switcher links are removed before alternatives can be provided Fixed - this is about allowing contrib/etc to provide better alternative links, which the core security fix broke.
We probably don't need all 3 tickets! For now, I suggest we keep the focus on π [regression] Language switcher block throws exception when no route is matched Fixed ?
- Status changed to Closed: works as designed
over 1 year ago 10:26am 21 March 2023 - π©πͺGermany mkalkbrenner π©πͺ
Alex helped me in slack. I found a piece of code in custom module that contained the same logic that has been changed in core's LanguageBlock in Drupal 9.5.5.
As soon as I replaced
$route_name = $this->pathMatcher->isFrontPage() ? '<front>' : '<current>'; $links = $this->languageManager->getLanguageSwitchLinks($type, Url::fromRoute($route_name));
by
$links = $this->languageManager->getLanguageSwitchLinks($type, Url::fromRouteMatch(\Drupal::routeMatch()));
the language switcher works again.
- π¨π¦Canada joseph.olstad
Thanks @alexpott for your assistance on this! We had similar custom code and @alexpott provided the cure.
- πͺπΈSpain hectorelgomez
Thanks a lot @joseph.olstad
It works perfect with D9.5.9