Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
[...] the function could be much simpler than it currently is. If it will always return 0 for registered users, why not make a conditional for that at the top of the function? There's also no need to keep all UIDs in the drupal_static(), keeping a single item with the SID of the anonymous user suffices.
See the discussion at #1619114: After cleaning cookies, flagging content as an anonymous user causes a PDO exception. for background.
Comment | File | Size | Author |
---|---|---|---|
#4 | 2072491-simplify_flag_set_sid-4.patch | 3.33 KB | a.ross |
#3 | 2072491-simplify_flag_set_sid-3.patch | 3.33 KB | a.ross |
#1 | 2072491-simplify_flag_set_sid-1.patch | 1.74 KB | a.ross |
Comments
Comment #1
a.ross CreditAttribution: a.ross commentedComment #2
a.ross CreditAttribution: a.ross commentedFrom #1619114: After cleaning cookies, flagging content as an anonymous user causes a PDO exception.
Comment #3
a.ross CreditAttribution: a.ross commentedComment #4
a.ross CreditAttribution: a.ross commentedNeeds re-roll.
Comment #5
joachim CreditAttribution: joachim commentedThis is where I think we can lose the $create parameter.
Can we definitely lose the $create here? Do we always call it with FALSE?
Comment #6
a.ross CreditAttribution: a.ross commentedNote that the solution I propose is slightly different from yours. I propose that the module should use
flag_get_sid($uid)
andflag_set_sid($uid)
everywhere, depending upon what's necessary (setting or merely getting). So you do away with using the second parameter, because you're now using the get/set pair properly :)In that case you MUST have the second parameter for the
flag_set_sid()
function, as that is called byflag_get_sid()
with$create = FALSE
. But you can do away with the second parameter forflag_get_sid()
altogether.Note these changes:
Second parameter passed value is the same as the default value (FALSE). Redundant.
Second parameter TRUE implies setting, so this can be converted to
flag_set_sid()
.