aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/cron.php
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2010-05-09 14:58:45 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2011-02-12 22:05:50 -0500
commit5c03040ddd531eabf495b48b626b72447c5d9b75 (patch)
tree20328952cc2eaf4ee4df78b7553520ac067c1a10 /phpBB/cron.php
parentd6fcea23a427322e70170f2a90e8efbea52926f6 (diff)
downloadforums-5c03040ddd531eabf495b48b626b72447c5d9b75.tar
forums-5c03040ddd531eabf495b48b626b72447c5d9b75.tar.gz
forums-5c03040ddd531eabf495b48b626b72447c5d9b75.tar.bz2
forums-5c03040ddd531eabf495b48b626b72447c5d9b75.tar.xz
forums-5c03040ddd531eabf495b48b626b72447c5d9b75.zip
[feature/system-cron] Try to work around stealth cron locks
Try to work around stealth cron locks resulting from fatal errors during cron processing. PHPBB3-9596
Diffstat (limited to 'phpBB/cron.php')
-rw-r--r--phpBB/cron.php39
1 files changed, 29 insertions, 10 deletions
diff --git a/phpBB/cron.php b/phpBB/cron.php
index 53540b58e2..92fef57623 100644
--- a/phpBB/cron.php
+++ b/phpBB/cron.php
@@ -48,25 +48,37 @@ function do_cron($run_tasks)
garbage_collection();
}
+// Thanks to various fatal errors and lack of try/finally, it is quite easy to leave
+// the cron lock locked, especially when working on cron-related code.
+//
+// Attempt to alleviate the problem by doing setup outside of the lock as much as possible.
+//
+// If DEBUG_EXTRA is defined and cron lock cannot be obtained, a message will be printed.
+
+if ($config['use_system_cron'])
+{
+ $use_shutdown_function = false;
+
+ include($phpbb_root_path . 'includes/cron/cron_manager.' . $phpEx);
+ $cron = new cron_manager;
+}
+else
+{
+ $cron_type = request_var('cron_type', '');
+ $use_shutdown_function = (@function_exists('register_shutdown_function')) ? true : false;
+
+ output_image();
+}
+
$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
{
- $cron_type = request_var('cron_type', '');
- $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);
@@ -95,3 +107,10 @@ if ($cron_lock->lock())
do_cron($run_tasks);
}
}
+else
+{
+ if (defined('DEBUG_EXTRA'))
+ {
+ echo "Could not obtain cron lock.";
+ }
+}