Passed
Push — development ( 2c0f7a...866d79 )
by Thomas
01:59
created

PurgeLogs::run()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 26
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 13
nc 4
nop 0
dl 0
loc 26
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/***************************************************************************
3
 *  For license information see doc/license.txt
4
 *
5
 *
6
 *  Delete old log entries with personal user data for data privacy
7
 ***************************************************************************/
8
9
checkJob(new PurgeLogs());
10
11
class PurgeLogs
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
12
{
13
    public $name = 'purge_logs';
14
    public $interval = 86400; // daily
15
16
    public function run()
17
    {
18
        global $opt;
19
20
        if ($opt['logic']['logs']['purge_email'] > 0) {
21
            sql(
22
                'DELETE FROM `email_user` WHERE date_created < NOW() - INTERVAL &1 DAY',
23
                $opt['logic']['logs']['purge_email']
24
            );
25
            sql(
26
                'DELETE FROM `logentries` WHERE date_created < NOW() - INTERVAL &1 DAY AND eventid IN (1,2,3,8)',
27
                $opt['logic']['logs']['purge_email']
28
            );
29
        }
30
31
        if ($opt['logic']['logs']['purge_userdata'] > 0) {
32
            sql(
33
                "DELETE FROM `logentries` WHERE date_created < NOW() - `INTERVAL` &1 DAY AND eventid IN (6,7)",
34
                $opt['logic']['logs']['purge_userdata']
35
            );
36
        }
37
38
        // Type 5 events = adoptions are still recorded here and preliminary archived,
39
        // but may be discarded after verifying that they are not used anywhere.
40
        // Adoptions are now in cache_adoptions table.
41
    }
42
}
43