vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Cron Job to Prune Thread (https://vborg.vbsupport.ru/showthread.php?t=280643)

tafreeh 03-25-2012 07:32 PM

Cron Job to Prune Thread
 
Hello,
How can I setup a Cron Job to permanently delete soft deleted thread && thread has been soft deleted for more than 7 days.

OR

Permanent Delete all threads from a forum that are only 7 days old. In this case Delete only X amount of threads per day.

Please guide.
Thanks

kh99 03-26-2012 08:41 PM

If you write a script to do what you described, you can put it in includes/cron and then create a new scheduled task to use it. You can look at the other scripts in that folder to see how they work.

I'm not sure if that's a lot of help - as for the thread pruning, you can find that code in an existing script and copy it. I think admincp/thread.php has code for when you do it from the admincp.

tafreeh 03-26-2012 11:45 PM

okay, I will look into it. But if someone else be more helpful that would be great !!

Thanks a lot kh99

Pandemikk 03-27-2012 04:26 AM

There's no easy way to tell, natively, when a thread has been soft deleted. However, a work-around to this would be to delete threads where the last post is older than 7 days ago and the thread is soft deleted. The reasoning behind this is that once a thread has been soft deleted it won't be posted in anymore.

Code:

define('ONE_WEEK', 604800);

$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "thread WHERE lastpost <= " . (TIMENOW - ONE_WEEK) . " AND visible = 0");

This will delete all soft deleted threads that haven't had a post in the past 7 days. Untested- should work fine.


All times are GMT. The time now is 05:15 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00968 seconds
  • Memory Usage 1,710KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete