The flag module is used to create a wishlist in a commerce shop. De shop has domain access installed.
When a javascript link is used, the view block (list off current items in wishlist) does not get refreshed (by the Views Flag Refresh module).

When a normal link is used, the user gets redirected to the front page after adding of removing a flag instead of staying on the same page.

This issue only occurs for non administrator users. This indicates that it is a permission issue.
I searched for hours but unfortunately didn't find the problem.

Does somebody know what is going wrong here?

Comments

joachim’s picture

> When a javascript link is used, the view block (list off current items in wishlist) does not get refreshed (by the Views Flag Refresh module).

If there are other parts of the page that depend on flag data, it's up to you to react to the AJAX link's JS events.

> When a normal link is used, the user gets redirected to the front page after adding of removing a flag instead of staying on the same page.

Can you debug the code that generates the URL for the link and see what's going wrong? It's in flag_flag_link() -- see what drupal_get_destination() is getting at that point.

mvdve’s picture

Thanks for the quick reply and good head start on the debugging.

The core issue is in the combination of flag and authcache (had to mention that in the first post, sorry).
When caching is enabled, drupal_get_destination() returns home (the raw $_GET['q'] also contains home) instead of the current page.

I created a temporary ugly hack by setting the link_href variable in the preprocess_flag hook to the associated node.

This fixed the issue when a normal link is used. The javascript link still gives this error from views:

Uncaught TypeError: Cannot read property 'top' of undefined

Authcache does come with a authcache_flag module. It is probability best to move this to there.

mvdve’s picture

Status: Active » Closed (outdated)