mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[feature/system-cron] Add array type hints if appropriate and remove globals.
PHPBB3-9596
This commit is contained in:
parent
165b0ec0b2
commit
9bc62056b2
2 changed files with 23 additions and 12 deletions
|
@ -30,7 +30,7 @@ function output_image()
|
||||||
echo base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
|
echo base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
|
||||||
|
|
||||||
// test without flush ;)
|
// test without flush ;)
|
||||||
// flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_cron($cron_lock, $run_tasks)
|
function do_cron($cron_lock, $run_tasks)
|
||||||
|
|
|
@ -30,15 +30,28 @@ class phpbb_cron_manager
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $tasks = array();
|
protected $tasks = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phpBB's root directory.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $phpbb_root_path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP file extension
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $phpEx;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Loads all available tasks.
|
* Constructor. Loads all available tasks.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct($phpbb_root_path, $phpEx)
|
||||||
{
|
{
|
||||||
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
|
$this->phpEx = $phpEx;
|
||||||
|
|
||||||
$task_names = $this->find_cron_task_names();
|
$task_names = $this->find_cron_task_names();
|
||||||
$this->load_tasks($task_names);
|
$this->load_tasks($task_names);
|
||||||
}
|
}
|
||||||
|
@ -59,12 +72,10 @@ class phpbb_cron_manager
|
||||||
*/
|
*/
|
||||||
public function find_cron_task_names()
|
public function find_cron_task_names()
|
||||||
{
|
{
|
||||||
global $phpbb_root_path, $phpEx;
|
$tasks_root_path = $this->phpbb_root_path . 'includes/cron/task/';
|
||||||
|
|
||||||
$tasks_root_path = $phpbb_root_path . 'includes/cron/task/';
|
|
||||||
|
|
||||||
$task_names = array();
|
$task_names = array();
|
||||||
$ext = '.' . $phpEx;
|
$ext = '.' . $this->phpEx;
|
||||||
$ext_length = strlen($ext);
|
$ext_length = strlen($ext);
|
||||||
|
|
||||||
$dh = opendir($tasks_root_path);
|
$dh = opendir($tasks_root_path);
|
||||||
|
@ -115,7 +126,7 @@ class phpbb_cron_manager
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function load_tasks($task_names)
|
public function load_tasks(array $task_names)
|
||||||
{
|
{
|
||||||
foreach ($task_names as $task_name)
|
foreach ($task_names as $task_name)
|
||||||
{
|
{
|
||||||
|
@ -196,7 +207,7 @@ class phpbb_cron_manager
|
||||||
*
|
*
|
||||||
* @return phpbb_cron_task_wrapper|null
|
* @return phpbb_cron_task_wrapper|null
|
||||||
*/
|
*/
|
||||||
public function instantiate_task($name, $args)
|
public function instantiate_task($name, array $args)
|
||||||
{
|
{
|
||||||
$task = $this->find_task($name);
|
$task = $this->find_task($name);
|
||||||
if ($task)
|
if ($task)
|
||||||
|
|
Loading…
Add table
Reference in a new issue