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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Here is the patch

andrewlevine’s picture

My 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.

andrewlevine’s picture

Status: Needs review » Reviewed & tested by the community

I 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 :)

andrewlevine’s picture

And here are my modifications

jaydub’s picture

Status: Reviewed & tested by the community » Needs work

Patch 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.

quicksketch’s picture

Status: Needs work » Needs review
FileSize
1.98 KB
2.24 KB

Here 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.

glitz’s picture

i 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

BigMike’s picture

@#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

BigMike’s picture

"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

quicksketch’s picture

"if I just wanted to reset all of my user's flagged content, would I just simply empty the flag_content table?"

Make 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.

BigMike’s picture

Thank you very much for this extra bit of info good Sir!

Got it done just now! Thanks! -Mike

glitz’s picture

Curious 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

joachim’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Needs review » Needs work

Upping the version, changing the status.