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.
See #719616: Keep flag_counts current by manual in/decreasing of count. of the original issue.
It would be cool if its configurable to cleanup the flag_content table to keep stuff.
This should be configurable per fid. I think we can make this a developer-only option.
Comment | File | Size | Author |
---|---|---|---|
#6 | flag_session_cleanup-d6.patch | 2.24 KB | quicksketch |
#6 | flag_session_cleanup-d7.patch | 1.98 KB | quicksketch |
#4 | 813342-flag-anonymous_cleanup_0.patch | 2.76 KB | andrewlevine |
#1 | 813342-flag-anonymous_cleanup.patch | 2.27 KB | dawehner |
Comments
Comment #1
dawehnerHere is the patch
Comment #2
andrewlevine CreditAttribution: andrewlevine commentedMy plan is to test the 2 patches on the train home in the next couple hours.
This code looks good, the one comment I have is to call the variable something like delete_expired_flag_data instead of something with "cleanup". Because in my opinion it's not that the table will not be clean, but it will have normalized data :). You guys might have a better name than I can come up with.
Comment #3
andrewlevine CreditAttribution: andrewlevine commentedI have made three small changes to this patch:
1. I changed the option name from session_api_cleanup to delete_expired_flag_content
2. I added a check for an empty $fids array so query errors won't occur when all flags are set to keep expired session flag_content
3. I added some comments explaining the option
I tested the original patch with 2 flags types with anonymous and user data (with the increment patch). One flag type was set to delete expired flag_content, the other not. Only the one set was deleted and only the anonymous data was deleted as expected. The counts were unaffected as expected.
I don't believe my changes should affect the correctness of the original patch but someone may want to check :)
Comment #4
andrewlevine CreditAttribution: andrewlevine commentedAnd here are my modifications
Comment #5
jaydub CreditAttribution: jaydub commentedPatch no longer applies cleanly with git apply, applies with some offset/fuzz with 'patch -p0'. Setting to needs work to get a clean git patch and since this is more than a year old, possibly to see if the code still applies.
Comment #6
quicksketchHere are patches for D6 and D7 branches. If any enterprising soul that needs this functionality can give it a review that would be great. In the mean time I don't see value in hurriedly adding this functionality, as it's rather obscure.
Note that I converted the D6 version to properly use db_placeholders() instead of just implode(',', $args).
The patch at #719616: Keep flag_counts current by manual in/decreasing of count. finally made it in too, so prerequisites for this patch are finally met.
Comment #7
glitz CreditAttribution: glitz commentedi will attempt this patch soon and post back.
im searching for a way to avoid a user "un-flagging" content. Instead, un-flagging would become automatic, say, after 5 hours of the user initial flagging.
------------------------
Ex: Flag for a "Check In"
A user visits a node (place) and flags "Check-in". The system would then automatically check the user out after 5 hours, therefore resets the flag for them for the next time they "Check in" at that same particualar place.
Hoping this patch points me in the right direction.
Thanks!
Chris
Comment #8
BigMike CreditAttribution: BigMike commented@#7 Chris, were you ever able to figure something like this out?
Also, if I just wanted to reset all of my user's flagged content, would I just simply empty the flag_content table?
Thanks
Mike
Comment #9
BigMike CreditAttribution: BigMike commented"if I just wanted to reset all of my user's flagged content, would I just simply empty the flag_content table?"
I just figured out this works.
Thanks,
Mike
Comment #10
quicksketchMake sure you also clear out the flag_counts table. You might get yourself into trouble if you have any other modules that make database entries on flag/unflag, but for basic installs emptying out the flag_content and flag_counts tables should work fine.
Comment #11
BigMike CreditAttribution: BigMike commentedThank you very much for this extra bit of info good Sir!
Got it done just now! Thanks! -Mike
Comment #12
glitz CreditAttribution: glitz commentedCurious to Know how this was done. also If there is a way to set a time limit per flag. Similar to: http://drupal.org/node/1352026
Comment #13
joachim CreditAttribution: joachim commentedUpping the version, changing the status.