aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/common.php11
-rwxr-xr-xphpBB/includes/emailer.php23
-rw-r--r--phpBB/index.php9
-rw-r--r--phpBB/install/schemas/mysql_basic.sql2
4 files changed, 32 insertions, 13 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index c30742eb9c..36d0d3377f 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -229,6 +229,17 @@ if (time() - $config['cache_interval'] >= $config['cache_last_gc'])
}
*/
+// Handle queue.
+if (time() - $config['queue_interval'] >= $config['last_queue_run'])
+{
+ if (file_exists($phpbb_root_path . 'cache/queue.' . $phpEx))
+ {
+ include($phpbb_root_path . 'includes/emailer.'.$phpEx);
+ $queue = new Queue();
+ $queue->process();
+ }
+}
+
// Show 'Board is disabled' message
if ($config['board_disable'] && !defined('IN_ADMIN') && !defined('IN_LOGIN'))
{
diff --git a/phpBB/includes/emailer.php b/phpBB/includes/emailer.php
index 0f6a08d6de..8deba01c4d 100755
--- a/phpBB/includes/emailer.php
+++ b/phpBB/includes/emailer.php
@@ -502,13 +502,20 @@ class Queue
echo "</pre>;";
}
+ // Thinking about a lock file...
function process()
{
- global $_SERVER, $_ENV;
+ global $_SERVER, $_ENV, $db;
if (file_exists($this->cache_file))
{
include($this->cache_file);
+ $fp = @fopen($this->cache_file, 'r');
+ @flock($fp, LOCK_EX);
+ }
+ else
+ {
+ return;
}
foreach ($this->queue_data as $object => $data_array)
@@ -550,11 +557,15 @@ class Queue
if (count($this->queue_data) == 0)
{
+ @flock($fp, LOCK_UN);
+ fclose($fp);
unlink($this->cache_file);
}
else
{
$file = '<?php $this->queue_data=' . $this->format_array($this->queue_data) . '; ?>';
+ @flock($fp, LOCK_UN);
+ fclose($fp);
if ($fp = @fopen($this->cache_file, 'wb'))
{
@@ -564,6 +575,11 @@ class Queue
fclose($fp);
}
}
+
+ $sql = "UPDATE " . CONFIG_TABLE . "
+ SET config_value = '" . time() . "'
+ WHERE config_name = 'last_queue_run'";
+ $db->sql_query();
}
function save()
@@ -581,9 +597,9 @@ class Queue
}
}
- $file = '<?php $this->queue_data=' . $this->format_array($this->data) . '; ?>';
+ $file = '<?php $this->queue_data = ' . $this->format_array($this->data) . '; ?>';
- if ($fp = @fopen($this->cache_file, 'wb'))
+ if ($fp = @fopen($this->cache_file, 'wt'))
{
@flock($fp, LOCK_EX);
fwrite($fp, $file);
@@ -592,7 +608,6 @@ class Queue
}
}
- // From acm_file.php
function format_array($array)
{
$lines = array();
diff --git a/phpBB/index.php b/phpBB/index.php
index 6947b2d677..f47a78c19c 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -47,15 +47,6 @@ if ($mark_read == 'forums')
trigger_error($message);
}
-// Handle queue - to be placed into common.php ? I think to only check and process at the index is enough. ;)
-// Do not initiate the object, we do not need to do this...
-if (file_exists($phpbb_root_path . 'cache/queue.' . $phpEx))
-{
- include($phpbb_root_path . 'includes/emailer.'.$phpEx);
- $queue = new Queue();
- $queue->process();
-}
-
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
$total_posts = $config['num_posts'];
$total_topics = $config['num_topics'];
diff --git a/phpBB/install/schemas/mysql_basic.sql b/phpBB/install/schemas/mysql_basic.sql
index ce7ab8974b..e8c02f1f8d 100644
--- a/phpBB/install/schemas/mysql_basic.sql
+++ b/phpBB/install/schemas/mysql_basic.sql
@@ -65,6 +65,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_lastread',
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_track', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('session_gc', '3600');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_gc', '7200');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('queue_interval', '600');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_check', '4');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('browser_check', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '2.1.1');
@@ -134,6 +135,7 @@ INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_po
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_topics', '1', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('session_last_gc', '0', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('search_last_gc', '0', 1);
+INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('last_queue_run', '0', 1);
# -- auth options
INSERT INTO phpbb_auth_options (auth_option, is_local) VALUES ('f_', 1);