Drupal 8.7.10 with PHP 7.3.11
Using the option on the settings page does not track the user moving through the site.
The current page seems to reset to the URI of the user when the cache is cleared. Following either menu bar links or book navigation links to other pages in the site does not change the "Current" page passed to the login page. The "?current=" link points to the URI at the time of cache rebuild.

Oddly if I open an Incognito window the current page set at cache rebuild time is carried over into the new Incognito browser window

Turning the caching on or off in the Performance config page does not seem to make any difference

Best to you

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

adam-bauer created an issue. See original summary.

shamilto2000’s picture

I'm having exactly the same problem. Any updates on this?

rsvelko’s picture

Question, guys, does this solve it for you?

https://www.drupal.org/project/login_destination/issues/3107857

jurgenr’s picture

Priority: Normal » Major

Changing priority to major as this is an important use case of the module.
At this moment the current querystring is set as the node ID of the first loaded page after clearing the cache, which can be any page and causes confusion for users logging in.

mlncn’s picture

The issue is very probably that menu blocks are cached per user (same for all pages), when we need them to also be cached per page.

mlncn’s picture

I used the Blocache (Block Cache Control) module to cache the block that had my menu per page.

A bit confused— i expected to change the footer menu cache to per page per user. Instead the per user part must be coming from the menu and its caching, while the blocks are cached generally by default. So i just added per page (URL) caching. Full configuration can be seen in this commit.

This is a workaround; if possible Login Destination module should identify blocks with login and logout menu links and update them accordingly.

In case it is useful to others, we're discussing the pros and cons of as an alternative to login destination for this purpose here.

remotedots’s picture

I think #5 is right. as a workaround i disabled the cache for my login block.

function THEME_preprocess_block(&$variables) {
  // dpm($variables);
  if ($variables['derivative_plugin_id'] == 'block_id') {
    $variables['#cache']['max-age'] = 0;
  }
gaurav.kapoor’s picture

I also noticed this issue and it is due to caching of menu links. The solution from https://www.drupal.org/project/login_destination/issues/3107857 doesn't solve it and only possible way is to disable caching for the menu link block. Only functionality affected from this is "Redirect from specific pages" setting isn't working.

gaurav.kapoor’s picture

The solution posted in https://drupal.stackexchange.com/a/288669 can also be used to solve caching issue.

Nigel Cunningham made their first commit to this issue’s fork.

nigelcunningham’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev

I came across this issue while investigating another issue that's already fixed in dev and have created the merge request, which adds a Trusted Callback pre-render hook, that sets the max-age for the link to zero. We could potentially add cache tags instead; this is just a quick and simple solution.

Updating the branch to 8.x-2.x since that's what I made the PR against.

nigelcunningham’s picture

Status: Active » Needs review
astringer’s picture

The merge request from #13 failed for me. 9.5.3, php 8.1 and 8.x-2.x beta 6(Applied, but I got this WSOD.)

I didn't have time to test it with another theme.

The website encountered an unexpected error. Please try again later.
TypeError: Drupal\bootstrap\Plugin\PrerenderManager::preRender(): Argument #1 ($element) must be of type array, null given in Drupal\bootstrap\Plugin\PrerenderManager::preRender() (line 36 of themes/contrib/bootstrap/src/Plugin/PrerenderManager.php).
Drupal\bootstrap\Plugin\PrerenderManager::preRender(NULL)
call_user_func_array(Array, Array) (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 788)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 374)
Drupal\Core\Render\Renderer->doRender(NULL) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 94)
template_preprocess_toolbar(Array, 'toolbar', Array)
call_user_func_array('template_preprocess_toolbar', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('toolbar', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 83)
__TwigTemplate_474fe8af4d3a856c59ebc5f7c9fa5132->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('themes/custom/itp_bs/templates/system/html.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 162)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 163)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 707)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

prudloff made their first commit to this issue’s fork.

prudloff’s picture

Disabling cache completely seems like overkill, we only need to make the cache vary based on path.

prudloff changed the visibility of the branch 3097721-redirect-to-current to hidden.

prudloff’s picture

Status: Needs review » Needs work

The MR now has conflicts.

prudloff’s picture

Status: Needs work » Needs review

Rebased the MR.

arousseau’s picture

Status: Needs review » Reviewed & tested by the community

MR 5 applies to the current 8.x-2.0-beta8 version and fixes the issue.
The "current" parameter appended to login and logout links varies based on the current page, while it does not without the patch.

It looks ok to merge.

rsvelko’s picture

Status: Reviewed & tested by the community » Fixed

Tested.
Approved.
Merged.
Fixed.

BTW on my local dev which is drupal 9.x, the current param was working ok.
Still works ok after the latest MR applied.
Probably my local dev is too simple, or the wrong drupal core version.

Status: Fixed » Closed (fixed)

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