[ticket/10046] Remove register_shutdown_function() in cron.php from develop.

PHPBB3-10046
This commit is contained in:
Andreas Fischer 2011-03-12 15:07:31 +01:00
parent df096b6b52
commit a627133b15
4 changed files with 2 additions and 67 deletions

View file

@ -62,14 +62,11 @@ function do_cron($cron_lock, $run_tasks)
if ($config['use_system_cron']) if ($config['use_system_cron'])
{ {
$use_shutdown_function = false;
$cron = new phpbb_cron_manager($phpbb_root_path . 'includes/cron/task', $phpEx, $cache->get_driver()); $cron = new phpbb_cron_manager($phpbb_root_path . 'includes/cron/task', $phpEx, $cache->get_driver());
} }
else else
{ {
$cron_type = request_var('cron_type', ''); $cron_type = request_var('cron_type', '');
$use_shutdown_function = (@function_exists('register_shutdown_function')) ? true : false;
// Comment this line out for debugging so the page does not return an image. // Comment this line out for debugging so the page does not return an image.
output_image(); output_image();
@ -95,22 +92,12 @@ if ($cron_lock->acquire())
} }
if ($task->is_ready()) if ($task->is_ready())
{ {
if ($use_shutdown_function && !$task->is_shutdown_function_safe())
{
$use_shutdown_function = false;
}
$run_tasks = array($task); $run_tasks = array($task);
} }
} }
} }
if ($use_shutdown_function)
{ do_cron($cron_lock, $run_tasks);
register_shutdown_function('do_cron', $cron_lock, $run_tasks);
}
else
{
do_cron($cron_lock, $run_tasks);
}
} }
else else
{ {

View file

@ -51,23 +51,4 @@ abstract class phpbb_cron_task_base implements phpbb_cron_task
{ {
return true; return true;
} }
/**
* Returns whether this cron task can be run in shutdown function.
*
* By the time shutdown sequence invokes a particular piece of code,
* resources that that code requires may already be released.
* If so, a particular cron task may be marked shutdown function-
* unsafe, and it will be executed in normal program flow.
*
* Generally speaking cron tasks should start off as shutdown function-
* safe, and only be marked shutdown function-unsafe if a problem
* is discovered.
*
* @return bool Whether the cron task is shutdown function-safe.
*/
public function is_shutdown_function_safe()
{
return true;
}
} }

View file

@ -64,21 +64,4 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base
global $config; global $config;
return $config['last_queue_run'] < time() - $config['queue_interval_config']; return $config['last_queue_run'] < time() - $config['queue_interval_config'];
} }
/**
* Returns whether this cron task can be run in shutdown function.
*
* A user reported that using the mail() function during shutdown
* function execution does not work. Therefore if email is delivered
* via the mail() function (as opposed to SMTP) queue cron task marks
* itself shutdown function-unsafe.
*
* @return bool
*/
public function is_shutdown_function_safe()
{
global $config;
// A user reported using the mail() function while using shutdown does not work. We do not want to risk that.
return !$config['smtp_delivery'];
}
} }

View file

@ -45,20 +45,4 @@ interface phpbb_cron_task
* @return bool * @return bool
*/ */
public function should_run(); public function should_run();
/**
* Returns whether this cron task can be run in shutdown function.
*
* By the time shutdown sequence invokes a particular piece of code,
* resources that that code requires may already be released.
* If so, a particular cron task may be marked shutdown function-
* unsafe, and it will be executed in normal program flow.
*
* Generally speaking cron tasks should start off as shutdown function-
* safe, and only be marked shutdown function-unsafe if a problem
* is discovered.
*
* @return bool
*/
public function is_shutdown_function_safe();
} }