[feature/system-cron] Changed include_once to *_exists/include.

PHPBB3-9596
This commit is contained in:
Oleg Pudeyev 2010-04-18 13:09:53 -04:00
parent fe72fe9878
commit ea3b98ab49
11 changed files with 70 additions and 16 deletions

View file

@ -16,7 +16,10 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
include_once($phpbb_root_path . 'includes/cron/cron_task_wrapper.' . $phpEx); if (!class_exists('cron_task_wrapper'))
{
include($phpbb_root_path . 'includes/cron/cron_task_wrapper.' . $phpEx);
}
/** /**
* Cron manager class. * Cron manager class.
@ -100,8 +103,11 @@ class cron_manager
list($mod, $filename) = $task_file; list($mod, $filename) = $task_file;
if ($this->is_valid_name($mod) && $this->is_valid_name($filename)) if ($this->is_valid_name($mod) && $this->is_valid_name($filename))
{ {
include_once($phpbb_root_path . "includes/cron/$mod/$filename.$phpEx");
$class = "cron_task_${mod}_${filename}"; $class = "cron_task_${mod}_${filename}";
if (!class_exists($class))
{
include($phpbb_root_path . "includes/cron/$mod/$filename.$phpEx");
}
$object = new $class; $object = new $class;
$wrapper = new cron_task_wrapper($object); $wrapper = new cron_task_wrapper($object);
$this->tasks[] = $wrapper; $this->tasks[] = $wrapper;

View file

@ -16,7 +16,10 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
include_once($phpbb_root_path . 'includes/cron/cron_task.' . $phpEx); if (!class_exists('cron_task'))
{
include_once($phpbb_root_path . 'includes/cron/cron_task.' . $phpEx);
}
/** /**
* Cron task base class. Provides sensible defaults for cron tasks * Cron task base class. Provides sensible defaults for cron tasks

View file

@ -16,6 +16,12 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
// We use parametrized_cron_task in is_parametrized
if (!interface_exists('cron_task'))
{
include($phpbb_root_path . 'includes/cron/cron_task.' . $phpEx);
}
/** /**
* Cron task wrapper class. * Cron task wrapper class.
* Enhances cron tasks with convenience methods that work identically for all tasks. * Enhances cron tasks with convenience methods that work identically for all tasks.

View file

@ -16,7 +16,10 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
include_once($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); if (!class_exists('cron_task_base'))
{
include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx);
}
/** /**
* Prune all forums cron task. * Prune all forums cron task.

View file

@ -16,7 +16,10 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
include_once($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); if (!class_exists('cron_task_base'))
{
include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx);
}
/** /**
* Prune one forum cron task. * Prune one forum cron task.
@ -60,7 +63,10 @@ class cron_task_core_prune_forum extends cron_task_base implements parametrized_
public function run() public function run()
{ {
global $phpbb_root_path, $phpEx; global $phpbb_root_path, $phpEx;
include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); if (!function_exists('auto_prune'))
{
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
}
if ($this->forum_data['prune_days']) if ($this->forum_data['prune_days'])
{ {

View file

@ -16,7 +16,10 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
include_once($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); if (!class_exists('cron_task_base'))
{
include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx);
}
/** /**
* Queue cron task. Sends email and jabber messages queued by other scripts. * Queue cron task. Sends email and jabber messages queued by other scripts.
@ -31,7 +34,10 @@ class cron_task_core_queue extends cron_task_base
public function run() public function run()
{ {
global $phpbb_root_path, $phpEx; global $phpbb_root_path, $phpEx;
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); if (!class_exists('queue'))
{
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
}
$queue = new queue(); $queue = new queue();
$queue->process(); $queue->process();
} }

View file

@ -16,7 +16,10 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
include_once($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); if (!class_exists('cron_task_base'))
{
include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx);
}
/** /**
* Tidy cache cron task. * Tidy cache cron task.

View file

@ -16,7 +16,10 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
include_once($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); if (!class_exists('cron_task_base'))
{
include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx);
}
/** /**
* Tidy database cron task. * Tidy database cron task.
@ -30,7 +33,10 @@ class cron_task_core_tidy_database extends cron_task_base
*/ */
public function run() public function run()
{ {
include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); if (!function_exists('tidy_database'))
{
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
}
tidy_database(); tidy_database();
} }

View file

@ -16,7 +16,10 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
include_once($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); if (!class_exists('cron_task_base'))
{
include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx);
}
/** /**
* Tidy search cron task. * Tidy search cron task.
@ -37,7 +40,10 @@ class cron_task_core_tidy_sessions extends cron_task_base
// Select the search method // Select the search method
$search_type = basename($config['search_type']); $search_type = basename($config['search_type']);
include_once("{$phpbb_root_path}includes/search/$search_type.$phpEx"); if (!class_exists($search_type))
{
include("{$phpbb_root_path}includes/search/$search_type.$phpEx");
}
// We do some additional checks in the module to ensure it can actually be utilised // We do some additional checks in the module to ensure it can actually be utilised
$error = false; $error = false;

View file

@ -16,7 +16,10 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
include_once($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); if (!class_exists('cron_task_base'))
{
include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx);
}
/** /**
* Tidy sessions cron task. * Tidy sessions cron task.

View file

@ -16,7 +16,10 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
include_once($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx); if (!class_exists('cron_task_base'))
{
include($phpbb_root_path . 'includes/cron/cron_task_base.' . $phpEx);
}
/** /**
* Tidy warnings cron task. * Tidy warnings cron task.
@ -33,7 +36,10 @@ class cron_task_core_tidy_warnings extends cron_task_base
public function run() public function run()
{ {
global $phpbb_root_path, $phpEx; global $phpbb_root_path, $phpEx;
include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); if (!function_exists('tidy_warnings'))
{
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
}
tidy_warnings(); tidy_warnings();
} }