Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
tidy_database
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 3
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 run
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 should_run
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14namespace phpbb\cron\task\core;
15
16/**
17* Tidy database cron task.
18*/
19class tidy_database extends \phpbb\cron\task\base
20{
21    protected $phpbb_root_path;
22    protected $php_ext;
23    protected $config;
24
25    /**
26    * Constructor.
27    *
28    * @param string $phpbb_root_path The root path
29    * @param string $php_ext The PHP file extension
30    * @param \phpbb\config\config $config The config
31    */
32    public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config)
33    {
34        $this->phpbb_root_path = $phpbb_root_path;
35        $this->php_ext = $php_ext;
36        $this->config = $config;
37    }
38
39    /**
40    * Runs this cron task.
41    *
42    * @return void
43    */
44    public function run()
45    {
46        if (!function_exists('tidy_database'))
47        {
48            include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext);
49        }
50        tidy_database();
51    }
52
53    /**
54    * Returns whether this cron task should run now, because enough time
55    * has passed since it was last run.
56    *
57    * The interval between database tidying is specified in board
58    * configuration.
59    *
60    * @return bool
61    */
62    public function should_run()
63    {
64        return $this->config['database_last_gc'] < time() - $this->config['database_gc'];
65    }
66}