Hi been pulling my hair trying to get this module to work for anon users for unflagging content.

My set-up is I have a list of content being generated by a view in a page. I also have the default bookmarks view in a block on the same page. Everything works perfectly in firefox but in both IE8 and Safari 4 I can add nodes to my favourites list. When I try and remove them by either clicking the remove link on the page view or block, I get a error of javascript and cookies arent enabled.

When I'm on the bookmarks page the remove faves link works perfectly from both the page and the block.

I have flags 2.0 beta4 and tried with both session api stable and dev.

Anyone got ideas?

CommentFileSizeAuthor
#6 js_anon_order.diff1.02 KBmooffie

Comments

derjochenmeyer’s picture

I have the exact same problem.

Quick Fix: When disabling the Normal Page cache it works.

But we need the caching :-/

derjochenmeyer’s picture

Title: Pulling my hair out removing favourites for anonymous users error javascript and cookies disabled IE8/Safari 4 » Removing favourites for anonymous users returns error: javascript and cookies disabled

I investigated more and found out that "sometimes" the the flag links dont get the ?has_js=1 query string attached.

Without this query string the links return a javascript error.

This Javascript snippet fixes the problem for me (quick & dirty):

Drupal.behaviors.fixFlag = function (context) {
  $('a.flag:not(.fixed-flag)', context).addClass('fixed-flag').each(function() {
    this.href += (this.href.match(/\?/) ? '&' : '?');
    this.href += (this.href.match(/\has_js/) ? '' : 'has_js=1');
  });
};

I use Firefox 3.6.12 on Windows XP

Rene Hostettler’s picture

Hi derjochenmeyer

Awesome that fixed it for me! Thanks heaps, have tested it in IE8 and safari 4

mooffie’s picture

(Jochen, thank you for finding a solution. I'm currently busy with other Flag issues so I haven't looked into this yet.)

derjochenmeyer’s picture

Title: Removing favourites for anonymous users returns error: javascript and cookies disabled » Removing flag for anonymous users returns error: javascript and cookies disabled
Priority: Major » Critical
Status: Active » Needs review

This needs to be fixed at the root. I dont know enough about the inner mechanics of flag to solve the problem, but maybe this helps to trace the bug...

This only happens for me with the normal page cache enabled.

Marking this as critical because it breaks one of the Key features for 2.x branch:

Flagging for anonymous users (even with page caching enabled). Requires Session API.

mooffie’s picture

StatusFileSize
new1.02 KB

I seem to have found the problem. (And contrary to the OP's report, this bug affects Firefox as well.)

Our JavaScript code currently does these two things, in this order:

  1. It calls Drupal.flagAnonymousLinkTemplates() to add has_js=1 to the links.
  2. It calls Drupal.flagAnonymousLinks() to "[swap] out links with their current state".

The bug is in the order: the addition of has_js=1 is done first, but it immediately gets overwritten by the second step.

The solution is to reverse the order. I'm attaching a patch.

mooffie’s picture

Status: Needs review » Fixed

Committed.
http://drupal.org/cvs?commit=462398
http://drupal.org/cvs?commit=462400

(Let me know if it doesn't solve your problem.)

derjochenmeyer’s picture

Patch #6 solved this issue for me.

Status: Fixed » Closed (fixed)

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