]> git.mxchange.org Git - friendica.git/blob - include/expire.php
Degrade priority step by step
[friendica.git] / include / expire.php
1 <?php
2
3 use Friendica\Core\Config;
4
5 function expire_run(&$argv, &$argc){
6         global $a;
7
8         require_once('include/datetime.php');
9         require_once('include/items.php');
10         require_once('include/Contact.php');
11
12         // physically remove anything that has been deleted for more than two months
13         $r = dba::p("SELECT `id` FROM `item` WHERE `deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY");
14         if (dbm::is_result($r)) {
15                 while ($row = dba::fetch($r)) {
16                         dba::delete('item', array('id' => $row['id']));
17                 }
18                 dba::close($r);
19         }
20
21         // make this optional as it could have a performance impact on large sites
22         if (intval(get_config('system', 'optimize_items'))) {
23                 q("OPTIMIZE TABLE `item`");
24         }
25
26         logger('expire: start');
27
28         $r = q("SELECT `uid`, `username`, `expire` FROM `user` WHERE `expire` != 0");
29         if (dbm::is_result($r)) {
30                 foreach ($r as $rr) {
31                         logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
32                         item_expire($rr['uid'], $rr['expire']);
33                 }
34         }
35
36         load_hooks();
37
38         call_hooks('expire');
39
40         return;
41 }