See the first post of the topic. Migration from 3.0 digest mod is supported. There is a code change on page 30 of this topic related to the tools class that should be applied before installing the extension on 3.2.stevenospam wrote: ↑Wed Apr 05, 2017 11:32 pm What is the best way to migrate to 3.2 and keep the digests config info for each user. Do I uninstall digests on the 3.0 board using STK? Leave digests installed on the 3.0 board? Other? On the 3.0 board digests is at the 2.2.23 level.
cron/task/digests.php
, around line 410 find:Code: Select all
// Get users requesting digests for the current hour. Also, grab the user's style, so the digest will have a familiar look.
Code: Select all
$allowed_user_types = 'AND ' . $this->db->sql_in_set('user_type', array(USER_FOUNDER, USER_NORMAL));
Code: Select all
AND user_inactive_reason = 0
Code: Select all
AND user_inactive_reason = 0 " . $allowed_user_types . "
Code: Select all
AND user_inactive_reason = 0
Code: Select all
AND user_inactive_reason = 0 " . $allowed_user_types . "
Code: Select all
// Execute the SQL to retrieve the relevant posts. Note, if $this->config['phpbbservices_digests_max_items'] == 0 then there is no limit on the rows returned
$result_posts = $this->db->sql_query_limit($sql_posts, $this->config['phpbbservices_digests_max_items']);
Code: Select all
$result_posts = $this->db->sql_query($sql_posts);
Code: Select all
$use_year = date($now, 'Y');
$use_month = date($now, 'n') - 1;
Code: Select all
$use_year = date('Y', $now);
$use_month = date('n', $now) - 1;
Code: Select all
$topic_first_poster_name = ''; // Keep PhpStorm happy
$username_clean = ''; // Keep PhpStorm happy
$post_time = array(); // Keep PhpStorm happy
$post_subject = ''; // Keep PhpStorm happy
$topic_last_post_time = ''; // Keep PhpStorm happy
$topic_replies = 0; // Keep PhpStorm happy
$topic_title = ''; // Keep PhpStorm happy
$topic_views = 0; // Keep PhpStorm happy
Code: Select all
$topic_first_poster_name = array(); // Keep PhpStorm happy
$username_clean = array(); // Keep PhpStorm happy
$post_time = array(); // Keep PhpStorm happy
$post_subject = array(); // Keep PhpStorm happy
$topic_last_post_time = array(); // Keep PhpStorm happy
$topic_replies = array(); // Keep PhpStorm happy
$topic_title = array(); // Keep PhpStorm happy
$topic_views = array(); // Keep PhpStorm happy
event/main_listener.php
Code: Select all
if ($this->config['phpbbservices_digests_enable_auto_subscriptions'] == 1 || $subscribe_on_registration)
Code: Select all
$is_human = ($event['sql_ary']['user_type'] == USER_IGNORE) ? false : true;
if ($is_human && ($this->config['phpbbservices_digests_enable_auto_subscriptions'] == 1 || $subscribe_on_registration))
/migrations/convert_mod_schema.php
Code: Select all
$tools = new \phpbb\db\tools($this->db);
Code: Select all
$tools_factory = new \phpbb\db\tools\factory();
$tools = $tools_factory->get($this->db);
Digest last sent (Based on 2 UTC)
was correctly set to Saturday 8. April 2017, 14:13
. You see the difference of one hour. I don't know whether it matters or not.Sa 8. Apr 16:29:39 CEST 2017
date("r");
returns Sat, 08 Apr 2017 16:29:36 +0200
.$recipient_time
yes, of course ... that's why I could start it controlled on command line and stop it after the third round.MarkDHamill wrote: ↑Sat Apr 08, 2017 3:06 pm In ACP > System settings. Is "Run periodic tasks from system cron" Yes or No?
/cron/task/digests.php
(the mailer) that sends out digests for how ever many hours are necessary. Starting around line 281:Code: Select all
for ($i=(1 - $hours_to_do); $i <= 0; $i++)
{
$success = $this->mail_digests($now, $i);
if (!$success)
{
// Need logic to notify or email admins when mailing digests fails. There are probably emailing issues needing fixing.
return false;
}
else if (!$this->manual_mode)
{
// Note that the hour was processed successfully.
$this->config->set('phpbbservices_digests_cron_task_last_gc', $now + ($i * 60 * 60));
}
}
$i
starts out as $i > 0
. $hours_to_do
is supposed to be a positive integer and should never be less than 1, otherwise the loop will continue forever.$hours_to_do gets
set:Code: Select all
// How many hours of digests are wanted? We want to do it for the number of hours between now and when digests were last ran successfully.
$hours_to_do = floor(($now - $this->config['phpbbservices_digests_cron_task_last_gc']) / (60 * 60));
$hours_to_do
will be a whole number if $this->config['phpbbservices_digests_cron_task_last_gc']
is less than $now
. $now
just reads the current time in UTC. On line 115:Code: Select all
$now = time();
$this->config['phpbbservices_digests_cron_task_last_gc']
(the time when digests were last run successfully) is after the current time or your server is incorrectly reporting the current time as a UTC timestamp. I doubt that latter case is possible.phpbb_
is your table prefix):SELECT from_unixtime(config_value), from_unixtime(unix_timestamp()) from phpbb_config where config_name = 'phpbbservices_digests_cron_task_last_gc'
Code: Select all
from_unixtime(config_value) from_unixtime(unix_timestamp())
2017-04-06 20:24:19 2017-04-08 20:45:53
should_run()
should keep the run function from running if an hour has not elapsed since digests were last sent out:Code: Select all
public function should_run()
{
return (bool) ($this->config['phpbbservices_digests_cron_task_last_gc'] + $this->config['phpbbservices_digests_cron_task_gc'] < time());
}
$this->config['phpbbservices_digests_cron_task_gc']
is set to 3600 (one hour) when digests are installed. You should check this value too.Code: Select all
// Process digests for each hour. For example, to do three hours, start with -2 hours from now and end after 0 hours from now (current hour).
if ($hours_to_do >= 1)
{
for ($i=(1 - $hours_to_do); ($i <= 0); $i++)
{
$success = $this->mail_digests($now, $i);
if (!$success)
{
// Need logic to notify or email admins when mailing digests fails. There are probably emailing issues needing fixing.
return false;
}
else if (!$this->manual_mode)
{
// Note that the hour was processed successfully.
$this->config->set('phpbbservices_digests_cron_task_last_gc', $now + ($i * 60 * 60));
}
}
}
SELECT from_unixtime(config_value), from_unixtime(unix_timestamp()) from phpbb_config where config_name = 'phpbbservices_digests_cron_task_last_gc'
shows Code: Select all
from_unixtime(config_value) from_unixtime(unix_timestamp())
2017-04-04 10:52:56 2017-04-09 09:55:10
phpbbservices_digests_cron_task_gc
is set to 3600