For anonymous users, the active/current menu item is not linked to anything. A closing "A" tag is provided, but no opening tag. This is happening on a clean install in both the Main Menu and a Custom Menu. Example resulting code:

Anonymous:

<li class="menu-item">
        Home</a>
</li>

Admin:

<li class="menu-item">
        <a href="/" data-drupal-link-system-path="&lt;front&gt;">Home</a>
</li>

I would prefer that the Anonymous user get the link, too.

Comments

rknox created an issue. See original summary.

rknox’s picture

Issue summary: View changes
rknox’s picture

I ended up doing the following, which seems to be working fine:

menu.html.twig

<li{{ item.attributes.addClass(classes) }}>
  REPLACE THIS LINE: {{ link(item.title, item.url) }}
  WITH THIS LINE: <a data-drupal-link-system-path="{{ item.url }}" title="{{ item.title }}" href="{{ item.url }}">{{ item.title }}</a>
    {% if item.below %}
      {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
    {% endif %}
</li>
rknox’s picture

Title: Active/Current Menu Item: No Link HREF for anonymous users » Active/Current Menu Item: Missing <A> tag for anonymous users
rknox’s picture

Version: 8.0.5 » 8.1.x-dev
mayurjadhav’s picture

Assigned: Unassigned » mayurjadhav
mayurjadhav’s picture

Assigned: mayurjadhav » Unassigned
Status: Active » Needs review
StatusFileSize
new666 bytes

Added patch with required changes.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

easp’s picture

The issue is also happening with the local task items. It looks like it needs to be fixed a different was as I don't see the URL value in twig.

wturrell’s picture

I'm unable to reproduce the original problem in 8.2.x / 8.3.x for anonymous users.
If it's still happening please clarify any steps to reproduce post-install.

ikit-claw’s picture

Status: Needs review » Reviewed & tested by the community

Tested in chrome chromium and firefox seems to be fixed from 8.2.5+

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work

Per #10 this still needs an issue summary. Also the last patch was tested against 8.1.x and actually failed, so this cannot go in like this.

rachel_norfolk’s picture

Support for bug fixes in the 8.1.x minor release finished when 8.2.0 was released. We don't need this bug fix to work on 8.1.x

See https://www.drupal.org/core/release-cycle-overview

An update to the Issue Summary will still be required, though. See https://www.drupal.org/node/1155816

dhansen’s picture

Status: Needs work » Closed (cannot reproduce)
Issue tags: -SprintWeekend2017

I'm going to go ahead and close this. I attempted to reproduce the issue as follows given the original version (8.0.5) the issue was reported on:

  1. Create Drupal 8.0.5 Install on SimplyTest.me
  2. Create new basic page, add to Main Menu
  3. Logout or open second browser to become anonymous user.
  4. Access new basic page in site menu
  5. Check markup on menu item. It still seems to be a whole <a> tag.

So between this and the other feedback in #10 I'm going to go ahead and assume there were other factors that did not get noted in the issue. We can certainly get another issue going or reopen this issue provided we get complete instructions to reproduce this in a current version.

jp.stacey’s picture

Issue tags: +SprintWeekend2017

Worked on during sprint weekend.

mfb’s picture

Version: 8.2.x-dev » 8.3.x-dev
Status: Closed (cannot reproduce) » Active

I can reproduce this on FreeBSD, and can fix the bug by disabling the ActiveLinkResponseFilter.

Perhaps there is some platform-specific issue related to LibXML, etc.? Because ActiveLinkResponseFilter is generating very wrong HTML output. This is the markup for main menu on a fresh Drupal 8.3.1 install, anonymous user:

<ul class="clearfix menu">
                    <li class="menu-item">
        Home</a>
              </li>
        </ul>
mfb’s picture

it would appear that on some platforms, the LIBXML_NOEMPTYTAG option is ignored for this line: $dom->saveXML($node, LIBXML_NOEMPTYTAG);.

As a result, the following line removes the <a> tag, and if we comment this line, the resulting markup is: <a href="/drupal-8.3.1/" data-drupal-link-system-path="&lt;front&gt;" class="is-active"/>Home</a> - note the self-closing <a /> tag.

So it would appear that to support all platforms, we need to strip out both possibilities: </a> closing tag or trailing / at the end of the <a /> tag.

mfb’s picture

Interestingly, I found that LIBXML_NOEMPTYTAG is ignored by the PHP Apache module, but works on the command-line.

mfb’s picture

Version: 8.3.x-dev » 8.4.x-dev
Status: Active » Needs review
StatusFileSize
new881 bytes

This patch resolves the issue for me, let's see what testbot thinks.

wturrell’s picture

@mfb - re: #18 – don't suppose you can compare your php -i CLI output with phpinfo(); in the browser and see if that turns up anything obvious?

e.g. check "DOM/XML API Version" or "libxml Version"

All my searching has turned up is the introduction of the (first) $node parameter to saveHTML() in PHP 5.3.6, and a couple of projects that have made the same switch you have..

Status: Needs review » Needs work

The last submitted patch, 19: 2695619-saveXML.patch, failed testing.

mfb’s picture

Status: Needs work » Needs review
StatusFileSize
new892 bytes

@wturrell I'm using libxml 2.9.4 (with Apache, LibXML, PHP, etc. compiled by FreeBSD ports)

It's not quite that easy to switch from saveXML() to saveHTML(), so here's a different tactic....

mfb’s picture

I didn't (yet) get any insight from bugs.php.net or IRC as to why LIBXML_NOEMPTYTAG is ignored by PHP apache2handler in my environment (but works on PHP cli). Upstream bug report is at https://bugs.php.net/bug.php?id=74494

wturrell’s picture

libxml 2.9.4 for me too (to test with Apache, I'm running it on an Acquia Dev Desktop install which has Apache 2.4.17, I've tried PHP 5.5,5.6 and 7)

mfb’s picture

In the end, I was able to resolve this bug in my system with some sysadmin fu (forcibly rebuilding packages and purging old libraries). Perhaps an older version of libxml was used despite PHP reporting 2.9.4?

This patch could still be helpful for anyone else who runs into this obscure issue, though.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mfb’s picture

Status: Needs review » Closed (cannot reproduce)

This should be closed again - it turned out to be related to having multiple versions of libxml installed on the system in question.