aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2010-04-18 13:48:32 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2011-02-12 22:05:49 -0500
commit763dc86c166ab850007fea8da4622e4cd1eeafc8 (patch)
tree27db57c6dd9b319b0355e379e46a161f20f44939 /phpBB
parentea3b98ab493c12442f7da1b52798294bcb086457 (diff)
downloadforums-763dc86c166ab850007fea8da4622e4cd1eeafc8.tar
forums-763dc86c166ab850007fea8da4622e4cd1eeafc8.tar.gz
forums-763dc86c166ab850007fea8da4622e4cd1eeafc8.tar.bz2
forums-763dc86c166ab850007fea8da4622e4cd1eeafc8.tar.xz
forums-763dc86c166ab850007fea8da4622e4cd1eeafc8.zip
[feature/system-cron] Fixes to make cron actually run.
PHPBB3-9596
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/common.php2
-rw-r--r--phpBB/cron.php20
-rw-r--r--phpBB/includes/cron/cron_manager.php13
-rw-r--r--phpBB/includes/cron/cron_task_base.php5
-rw-r--r--phpBB/includes/cron/tasks/core/tidy_database.php1
-rw-r--r--phpBB/includes/cron/tasks/core/tidy_search.php2
6 files changed, 26 insertions, 17 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index e2300f0bd5..cbd8399206 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -243,5 +243,5 @@ foreach ($cache->obtain_hooks() as $hook)
if (!$config['use_system_cron'])
{
include($phpbb_root_path . 'includes/cron/cron_manager.' . $phpEx);
- $cron = new cron();
+ $cron = new cron_manager();
}
diff --git a/phpBB/cron.php b/phpBB/cron.php
index 0621d7651b..53540b58e2 100644
--- a/phpBB/cron.php
+++ b/phpBB/cron.php
@@ -48,12 +48,16 @@ function do_cron($run_tasks)
garbage_collection();
}
+$cron_lock = new cron_lock;
if ($cron_lock->lock())
{
if ($config['use_system_cron'])
{
$use_shutdown_function = false;
+ include($phpbb_root_path . 'includes/cron/cron_manager.' . $phpEx);
+ $cron = new cron_manager;
+
$run_tasks = $cron->find_all_ready_tasks();
}
else
@@ -62,14 +66,20 @@ if ($cron_lock->lock())
$use_shutdown_function = (@function_exists('register_shutdown_function')) ? true : false;
output_image();
-
+
+ // If invalid task is specified, empty $run_tasks is passed to do_cron which then does nothing
+ $run_tasks = array();
$task = $cron->find_task($cron_type);
- if ($task) {
- if ($task->is_parametrized()) {
+ if ($task)
+ {
+ if ($task->is_parametrized())
+ {
$task->parse_parameters($_GET);
}
- if ($task->is_ready()) {
- if ($use_shutdown_function && !$task->is_shutdown_function_safe()) {
+ if ($task->is_ready())
+ {
+ if ($use_shutdown_function && !$task->is_shutdown_function_safe())
+ {
$use_shutdown_function = false;
}
$run_tasks = array($task);
diff --git a/phpBB/includes/cron/cron_manager.php b/phpBB/includes/cron/cron_manager.php
index a99f1369de..5c3bfd01b5 100644
--- a/phpBB/includes/cron/cron_manager.php
+++ b/phpBB/includes/cron/cron_manager.php
@@ -61,7 +61,7 @@ class cron_manager
{
// ignore ., .. and dot directories
// todo: change is_dir to account for symlinks
- if ($entry[0] == '.' || !is_dir($entry))
+ if ($entry[0] == '.' || !is_dir("$tasks_root_path/$entry"))
{
continue;
}
@@ -76,10 +76,13 @@ class cron_manager
{
$path = $phpbb_root_path . 'includes/cron/tasks/' . $task_dir;
$dir = opendir($path);
- while (($entry = readdir($dir)) !== false && substr($entry, -$ext_length) == $ext)
+ while (($entry = readdir($dir)) !== false)
{
- $task_file = substr($entry, 0, -$ext_length);
- $task_files[] = array($task_dir, $task_file);
+ if (substr($entry, -$ext_length) == $ext)
+ {
+ $task_file = substr($entry, 0, -$ext_length);
+ $task_files[] = array($task_dir, $task_file);
+ }
}
closedir($dir);
}
@@ -106,7 +109,7 @@ class cron_manager
$class = "cron_task_${mod}_${filename}";
if (!class_exists($class))
{
- include($phpbb_root_path . "includes/cron/$mod/$filename.$phpEx");
+ include($phpbb_root_path . "includes/cron/tasks/$mod/$filename.$phpEx");
}
$object = new $class;
$wrapper = new cron_task_wrapper($object);
diff --git a/phpBB/includes/cron/cron_task_base.php b/phpBB/includes/cron/cron_task_base.php
index a75e27ac13..f35ecd4ae0 100644
--- a/phpBB/includes/cron/cron_task_base.php
+++ b/phpBB/includes/cron/cron_task_base.php
@@ -35,11 +35,6 @@ if (!class_exists('cron_task'))
abstract class cron_task_base implements cron_task
{
/**
- * Runs this cron task.
- */
- abstract public function run();
-
- /**
* Returns whether this cron task can run, given current board configuration.
*
* For example, a cron task that prunes forums can only run when
diff --git a/phpBB/includes/cron/tasks/core/tidy_database.php b/phpBB/includes/cron/tasks/core/tidy_database.php
index f2de216c3a..6724ec092e 100644
--- a/phpBB/includes/cron/tasks/core/tidy_database.php
+++ b/phpBB/includes/cron/tasks/core/tidy_database.php
@@ -33,6 +33,7 @@ class cron_task_core_tidy_database extends cron_task_base
*/
public function run()
{
+ global $phpbb_root_path, $phpEx;
if (!function_exists('tidy_database'))
{
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
diff --git a/phpBB/includes/cron/tasks/core/tidy_search.php b/phpBB/includes/cron/tasks/core/tidy_search.php
index 42a46142b1..e821310c9f 100644
--- a/phpBB/includes/cron/tasks/core/tidy_search.php
+++ b/phpBB/includes/cron/tasks/core/tidy_search.php
@@ -28,7 +28,7 @@ if (!class_exists('cron_task_base'))
*
* @package phpBB3
*/
-class cron_task_core_tidy_sessions extends cron_task_base
+class cron_task_core_tidy_search extends cron_task_base
{
/**
* Runs this cron task.