Global flags set the uid to 0 in the {flagging} table.

Meanwhile flag_get_user_flag_counts() adds a condition on the uid field.

That means what flag_get_user_flag_counts() will always return 0 for a given flag and user if the flag is global.

Given that the purpose of flag_get_user_flag_counts() is to return the number of flaggings the user has made with a given flag, this makes sense.

However, this should be documented in the function -- that it doesn't serve global flags at all.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Title: flag_get_user_flag_counts() doesn't work for global flags - should it? » flag_get_user_flag_counts() doesn't work for global flags
cs_shadow’s picture

Status: Active » Needs review
FileSize
460 bytes

Added a line in documentation that this method does not serves global flags. Any suggestions are welcome.

joachim’s picture

Title: flag_get_user_flag_counts() doesn't work for global flags » documement that flag_get_user_flag_counts() doesn't work for global flags
joachim’s picture

Title: documement that flag_get_user_flag_counts() doesn't work for global flags » document that flag_get_user_flag_counts() doesn't work for global flags
joachim’s picture

Status: Needs review » Fixed

Committed! Sorry for the long delay. Thanks for the patch!

  • joachim committed c30ac29 on 7.x-3.x authored by cs_shadow
    Issue #2208759 by cs_shadow: Fixed flag_get_user_flag_counts() not...

Status: Fixed » Closed (fixed)

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