public function execute() {
        global $DB;

        // Check if the category bin is disabled or there is no expiry time.
        $lifetime = get_config('tool_recyclebin', 'categorybinexpiry');
        if (!\tool_recyclebin\category_bin::is_enabled() || $lifetime <= 0) {
            return true;
        }

        // Get the items we can delete.
        $items = $DB->get_recordset_select('tool_recyclebin_category', 'timecreated <= :timecreated',
            array('timecreated' => time() - $lifetime));
        foreach ($items as $item) {
            mtrace("[tool_recyclebin] Deleting item '{$item->id}' from the category recycle bin ...");
            $bin = new \tool_recyclebin\category_bin($item->categoryid);
            $bin->delete_item($item);
        }
        $items->close();

        return true;
    }
public function execute() {
        global $DB;

        // Check if the category bin is disabled or there is no expiry time.
        $lifetime = get_config('tool_recyclebin', 'categorybinexpiry');
        if (!\tool_recyclebin\category_bin::is_enabled() || $lifetime <= 0) {
            return true;
        }

        // Get the items we can delete.
        $items = $DB->get_recordset_select('tool_recyclebin_category', 'timecreated <= :timecreated',
            array('timecreated' => time() - $lifetime));
        foreach ($items as $item) {
            mtrace("[tool_recyclebin] Deleting item '{$item->id}' from the category recycle bin ...");
            $bin = new \tool_recyclebin\category_bin($item->categoryid);
            $bin->delete_item($item);
        }
        $items->close();

        return true;
    }
public function execute ( ) { global $ DB ; // Check if the category bin is disabled or there is no expiry time. $ lifetime = get_config ( 'tool_recyclebin' , 'categorybinexpiry' ) ; if ( ! \ tool_recyclebin \ category_bin :: is_enabled ( ) || $ lifetime <= 0 ) { return true ; } // Get the items we can delete. $ items = $ DB -> get_recordset_select ( 'tool_recyclebin_category' , 'timecreated <= :timecreated' , array ( 'timecreated' => time ( ) - $ lifetime ) ) ; foreach ( $ items as $ item ) { mtrace ( "[tool_recyclebin] Deleting item '{$item->id}' from the category recycle bin ..." ) ; $ bin = new \ tool_recyclebin \ category_bin ( $ item -> categoryid ) ; $ bin -> delete_item ( $ item ) ; } $ items -> close ( ) ; return true ; }
Delete all expired items.
Delete all expired items .