]> git.mxchange.org Git - friendica.git/blobdiff - include/expire.php
Merge pull request #3463 from friendica/develop
[friendica.git] / include / expire.php
index 35b109a50a487156ac53fe3d3ec66bfb1c9906e6..73bffb20dce37a89e88714afdf7611634da2b8c4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-use \Friendica\Core\Config;
+use Friendica\Core\Config;
 
 function expire_run(&$argv, &$argc){
        global $a;
@@ -10,13 +10,19 @@ function expire_run(&$argv, &$argc){
        require_once('include/Contact.php');
 
        // physically remove anything that has been deleted for more than two months
-
-       $r = q("delete from item where deleted = 1 and changed < UTC_TIMESTAMP() - INTERVAL 60 DAY");
+       $r = dba::p("SELECT `id` FROM `item` WHERE `deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY");
+       if (dbm::is_result($r)) {
+               while ($row = dba::fetch($r)) {
+                       dba::delete('item', array('id' => $row['id']));
+               }
+               dba::close($r);
+       }
 
        // make this optional as it could have a performance impact on large sites
 
-       if(intval(get_config('system','optimize_items')))
-               q("optimize table item");
+       if (intval(get_config('system','optimize_items'))) {
+               q("OPTIMIZE TABLE `item`");
+       }
 
        logger('expire: start');