[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/cron/task/core/ -> tidy_search.php (source)

   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  
  14  namespace phpbb\cron\task\core;
  15  
  16  /**
  17  * Tidy search cron task.
  18  *
  19  * Will only run when the currently selected search backend supports tidying.
  20  */
  21  class tidy_search extends \phpbb\cron\task\base
  22  {
  23      /**
  24      * phpBB root path
  25      * @var string
  26      */
  27      protected $phpbb_root_path;
  28  
  29      /**
  30      * PHP file extension
  31      * @var string
  32      */
  33      protected $php_ext;
  34  
  35      /**
  36      * Auth object
  37      * @var \phpbb\auth\auth
  38      */
  39      protected $auth;
  40  
  41      /**
  42      * Config object
  43      * @var \phpbb\config\config
  44      */
  45      protected $config;
  46  
  47      /**
  48      * Database object
  49      * @var \phpbb\db\driver\driver_interface
  50      */
  51      protected $db;
  52  
  53      /**
  54      * User object
  55      * @var \phpbb\user
  56      */
  57      protected $user;
  58  
  59      /**
  60      * Event dispatcher object
  61      * @var \phpbb\event\dispatcher_interface
  62      */
  63      protected $phpbb_dispatcher;
  64  
  65      /**
  66      * Constructor.
  67      *
  68      * @param string $phpbb_root_path The phpBB root path
  69      * @param string $php_ext The PHP file extension
  70      * @param \phpbb\auth\auth $auth The auth object
  71      * @param \phpbb\config\config $config The config object
  72      * @param \phpbb\db\driver\driver_interface $db The database object
  73      * @param \phpbb\user $user The user object
  74      * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher The event dispatcher object
  75      */
  76  	public function __construct($phpbb_root_path, $php_ext, \phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, \phpbb\event\dispatcher_interface $phpbb_dispatcher)
  77      {
  78          $this->phpbb_root_path = $phpbb_root_path;
  79          $this->php_ext = $php_ext;
  80          $this->auth = $auth;
  81          $this->config = $config;
  82          $this->db = $db;
  83          $this->user = $user;
  84          $this->phpbb_dispatcher = $phpbb_dispatcher;
  85      }
  86  
  87      /**
  88      * Runs this cron task.
  89      *
  90      * @return null
  91      */
  92  	public function run()
  93      {
  94          $search_type = $this->config['search_type'];
  95  
  96          // We do some additional checks in the module to ensure it can actually be utilised
  97          $error = false;
  98          $search = new $search_type($error, $this->phpbb_root_path, $this->php_ext, $this->auth, $this->config, $this->db, $this->user, $this->phpbb_dispatcher);
  99  
 100          if (!$error)
 101          {
 102              $search->tidy();
 103          }
 104      }
 105  
 106      /**
 107      * Returns whether this cron task can run, given current board configuration.
 108      *
 109      * Search cron task is runnable in all normal use. It may not be
 110      * runnable if the search backend implementation selected in board
 111      * configuration does not exist.
 112      *
 113      * @return bool
 114      */
 115  	public function is_runnable()
 116      {
 117          return class_exists($this->config['search_type']);
 118      }
 119  
 120      /**
 121      * Returns whether this cron task should run now, because enough time
 122      * has passed since it was last run.
 123      *
 124      * The interval between search tidying is specified in board
 125      * configuration.
 126      *
 127      * @return bool
 128      */
 129  	public function should_run()
 130      {
 131          return $this->config['search_last_gc'] < time() - $this->config['search_gc'];
 132      }
 133  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1