Background jobs are not loading user settings properly

master
Frederic Guillot 6 years ago
parent 4ab9ca165c
commit d9295207b0
  1. 17
      cronjob.php
  2. 5
      worker.php

@ -4,6 +4,7 @@ require __DIR__.'/app/common.php';
use Miniflux\Handler;
use Miniflux\Model;
use Miniflux\Session\SessionStorage;
if (php_sapi_name() === 'cli') {
$options = getopt('', array(
@ -25,17 +26,23 @@ if (php_sapi_name() === 'cli') {
$limit = get_cli_option('limit', $options);
$update_interval = get_cli_option('update-interval', $options);
$call_interval = get_cli_option('call-interval', $options);
$session = SessionStorage::getInstance();
foreach (Model\User\get_all_user_ids() as $user_id) {
$session->flush();
$session->setUser(Model\User\get_user_by_id($user_id));
foreach (Model\User\get_all_users() as $user) {
if ($update_interval !== null && $call_interval !== null && $limit === null && $update_interval >= $call_interval) {
$feeds_count = Model\Feed\count_feeds($user['id']);
$feeds_count = Model\Feed\count_feeds($user_id);
$current_limit = ceil($feeds_count / ($update_interval / $call_interval));
} else {
$current_limit = $limit;
}
Handler\Feed\update_feeds($user['id'], $current_limit);
Model\Item\autoflush_read($user['id']);
Model\Item\autoflush_unread($user['id']);
echo 'Update feeds for user_id='.$user_id.', limit='.$current_limit.PHP_EOL;
Handler\Feed\update_feeds($user_id, $current_limit);
Model\Item\autoflush_read($user_id);
Model\Item\autoflush_unread($user_id);
Miniflux\Helper\write_debug_file();
}

@ -2,6 +2,7 @@
use Miniflux\Handler;
use Miniflux\Model;
use Miniflux\Session\SessionStorage;
use Pheanstalk\Pheanstalk;
require __DIR__.'/app/common.php';
@ -11,6 +12,7 @@ if (php_sapi_name() !== 'cli') {
}
$connection = new Pheanstalk(BEANSTALKD_HOST);
$session = SessionStorage::getInstance();
while ($job = $connection->reserveFromTube(BEANSTALKD_QUEUE)) {
$payload = unserialize($job->getData());
@ -18,6 +20,9 @@ while ($job = $connection->reserveFromTube(BEANSTALKD_QUEUE)) {
echo 'Processing feed_id=', $payload['feed_id'], ' for user_id=', $payload['user_id'];
$session->flush();
$session->setUser(Model\User\get_user_by_id($payload['user_id']));
Handler\Feed\update_feed($payload['user_id'], $payload['feed_id']);
Model\Item\autoflush_read($payload['user_id']);
Model\Item\autoflush_unread($payload['user_id']);

Loading…
Cancel
Save