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

Files: 
CommentFileSizeAuthor
#12 1792584-2.flag_.user-profile-two-links_12.patch3.57 KBscor
PASSED: [[SimpleTest]]: [MySQL] 61 pass(es).
[ View ]
#11 1792584-2.flag_.user-profile-two-links.patch3.93 KBjoachim
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1792584-2.flag_.user-profile-two-links.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#7 1792584.flag_.user-profile-two-links.patch3.61 KBjoachim
PASSED: [[SimpleTest]]: [MySQL] 65 pass(es).
[ View ]
flag.jpg28.12 KBsemei

Comments

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

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.

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.

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.

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?

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

Status:Active» Needs review
StatusFileSize
new3.61 KB
PASSED: [[SimpleTest]]: [MySQL] 65 pass(es).
[ View ]

Tagging.

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.

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.

Version:7.x-3.x-dev» 7.x-2.x-dev
Status:Fixed» Patch (to be ported)
StatusFileSize
new3.93 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1792584-2.flag_.user-profile-two-links.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

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.

Status:Patch (to be ported)» Needs review
StatusFileSize
new3.57 KB
PASSED: [[SimpleTest]]: [MySQL] 61 pass(es).
[ View ]

backported patch against 7.x-2.x

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

Status:Needs review» Fixed

Committed. Thanks!

Status:Fixed» Closed (fixed)

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