Hi y'all,

I created a user flag called "follow" and chose to have the link displayed on the user profile page. On the user profile pages however, the link appears twice. You can find a screenshot in the attachment.

Best,
semei

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Version: 7.x-2.0 » 7.x-3.x-dev
Component: User interface » Flag core

Confirming this.

As a workaround, if you disable 'Display link on user profile page' you'll only get one.

Then problem is, I think, that we have two things happening at once:

- hook_entity_view() tries to show the link on the entity
- the 'Display link on user profile page' option is providing one too

joachim’s picture

More digging: the two things that show the link are:

- hook_entity_view(), tries to do this by checking $flag->uses_hook_link()
- flag_user_view, tries to do this by checking $flag->uses_hook_link()

And while in flag_entity, uses_hook_link() just checks $this->show_on_entity, in flag_user it checks $this->show_on_profile.

So clearly, the expectation is that user entities do their own work to show the link. But that probably dates back to D6, and now users can have this done for them.

Thus we could drop the special handling. But on the other hand, user profiles have a fairly specific formatting that we provide. So I think we should keep that.

My hunch is that we should drop the uses_hook_link() check from flag_user_view and check directly with the 'show_on_profile' property. Having the same access method check different properties under the hood seems a bit iffy to me anyway.

joachim’s picture

Hmm though this pattern is really the way uses_hook_link() seems to be meant to work: it wraps up the various type-specific properties.

joachim’s picture

We have several possible ways to fix this:

- keep the current special output on users, with the current UI options, and make hook_entity_view() aware that it has to skip the 'user' entity type. This would presumably mean an extra setting somewhere in the flag class.
- keep both ways of adding a flag to user entities. Have flag_user keep the 'show_on_entity' UI option (rather than removing it as it currently does). User flags then have both 'show_on_entity' AND 'show_on_profile'. Which is potentially confusing UI, but that can be mitigated with an explanation that 'show_on_profile' means 'format it nicely'.

I'm inclined to go got the second fix.

martichka5’s picture

Hi,

I have the same problem. In the user profile page there are two links provided by the flag module from the flag i created.
Is there a solution for the issue?

joachim’s picture

See my earlier comment above for a couple of potential approaches. Someone who wants this fix needs to actually do the work :)

joachim’s picture

Status: Active » Needs review
FileSize
3.61 KB
joachim’s picture

Tagging.

joachim’s picture

This allows two instances of the same flag on the user profile, hence we should also commit #843308: Support multiple instances of the same flag on single node view pages.

joachim’s picture

Status: Needs review » Fixed

Nobody testing this? :(

Oh well -- committing, as tests pass, it works fine for me and I don't want this to rot or hold up other issues.

Issue #1792584 by joachim: Fixed flag links displayed twice on user profile.

joachim’s picture

Version: 7.x-3.x-dev » 7.x-2.x-dev
Status: Fixed » Patch (to be ported)
FileSize
3.93 KB

Patch will need a bit of work to backport to 2.x, if anyone's interested.

Here's the slightly updated version of what I committed -- just has an extra comment.

scor’s picture

Status: Patch (to be ported) » Needs review
FileSize
3.57 KB

backported patch against 7.x-2.x

alexweber’s picture

Removing 3.x release blocker tag since it's been committed and now the issue is for 2.x

joachim’s picture

Status: Needs review » Fixed

Committed. Thanks!

Status: Fixed » Closed (fixed)

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