mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/14814] Fix reparser cron
PHPBB3-14814
This commit is contained in:
parent
7bb4e88acd
commit
d90afa67d8
3 changed files with 22 additions and 8 deletions
|
@ -208,7 +208,7 @@ class reparse extends \phpbb\console\command\command
|
||||||
$size = $this->get_option('range-size');
|
$size = $this->get_option('range-size');
|
||||||
|
|
||||||
// range-max has no default value, it must be computed for each reparser
|
// range-max has no default value, it must be computed for each reparser
|
||||||
if ($max == null)
|
if ($max === null)
|
||||||
{
|
{
|
||||||
$max = $reparser->get_max_id();
|
$max = $reparser->get_max_id();
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ class reparser extends \phpbb\cron\task\base
|
||||||
$this->reparser_manager->get_resume_data($this->reparser_name);
|
$this->reparser_manager->get_resume_data($this->reparser_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->resume_data['range-max']) || $this->resume_data['range-max'] >= $this->resume_data['range-min'])
|
if (!isset($this->resume_data['range-max']) || $this->resume_data['range-max'] >= $this->resume_data['range-min'])
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -147,9 +147,9 @@ class reparser extends \phpbb\cron\task\base
|
||||||
*/
|
*/
|
||||||
$reparser = $this->reparsers[$this->reparser_name];
|
$reparser = $this->reparsers[$this->reparser_name];
|
||||||
|
|
||||||
$min = !empty($this->resume_data['range-min']) ? $this->resume_data['range-min'] : self::MIN;
|
$min = isset($this->resume_data['range-min']) ? $this->resume_data['range-min'] : self::MIN;
|
||||||
$current = !empty($this->resume_data['range-max']) ? $this->resume_data['range-max'] : $reparser->get_max_id();
|
$current = isset($this->resume_data['range-max']) ? $this->resume_data['range-max'] : $reparser->get_max_id();
|
||||||
$size = !empty($this->resume_data['range-size']) ? $this->resume_data['range-size'] : self::SIZE;
|
$size = isset($this->resume_data['range-size']) ? $this->resume_data['range-size'] : self::SIZE;
|
||||||
|
|
||||||
if ($current >= $min)
|
if ($current >= $min)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
|
|
||||||
namespace phpbb\db\migration\data\v320;
|
namespace phpbb\db\migration\data\v320;
|
||||||
|
|
||||||
|
use phpbb\textreparser\manager;
|
||||||
|
use phpbb\textreparser\reparser_interface;
|
||||||
|
|
||||||
class text_reparser extends \phpbb\db\migration\container_aware_migration
|
class text_reparser extends \phpbb\db\migration\container_aware_migration
|
||||||
{
|
{
|
||||||
static public function depends_on()
|
static public function depends_on()
|
||||||
|
@ -48,7 +51,19 @@ class text_reparser extends \phpbb\db\migration\container_aware_migration
|
||||||
|
|
||||||
public function reparse($resume_data)
|
public function reparse($resume_data)
|
||||||
{
|
{
|
||||||
// Somtimes a cron job is too much
|
/** @var manager $reparser_manager */
|
||||||
|
$reparser_manager = $this->container->get('text_reparser.manager');
|
||||||
|
|
||||||
|
/** @var reparser_interface[] $reparsers */
|
||||||
|
$reparsers = $this->container->get('text_reparser_collection');
|
||||||
|
|
||||||
|
// Initialize all reparsers
|
||||||
|
foreach ($reparsers as $name => $reparser)
|
||||||
|
{
|
||||||
|
$reparser_manager->update_resume_data($name, 1, $reparser->get_max_id(), 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sometimes a cron job is too much
|
||||||
$limit = 100;
|
$limit = 100;
|
||||||
$fast_reparsers = array(
|
$fast_reparsers = array(
|
||||||
'text_reparser.contact_admin_info',
|
'text_reparser.contact_admin_info',
|
||||||
|
@ -65,7 +80,7 @@ class text_reparser extends \phpbb\db\migration\container_aware_migration
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fast_reparsers_size = sizeof($fast_reparsers);
|
$fast_reparsers_size = count($fast_reparsers);
|
||||||
$processed_records = 0;
|
$processed_records = 0;
|
||||||
while ($processed_records < $limit && $resume_data['reparser'] < $fast_reparsers_size)
|
while ($processed_records < $limit && $resume_data['reparser'] < $fast_reparsers_size)
|
||||||
{
|
{
|
||||||
|
@ -87,7 +102,6 @@ class text_reparser extends \phpbb\db\migration\container_aware_migration
|
||||||
if ($start === 1)
|
if ($start === 1)
|
||||||
{
|
{
|
||||||
// Prevent CLI command from running these reparsers again
|
// Prevent CLI command from running these reparsers again
|
||||||
$reparser_manager = $this->container->get('text_reparser.manager');
|
|
||||||
$reparser_manager->update_resume_data($fast_reparsers[$resume_data['reparser']], 1, 0, $limit);
|
$reparser_manager->update_resume_data($fast_reparsers[$resume_data['reparser']], 1, 0, $limit);
|
||||||
|
|
||||||
$resume_data['reparser']++;
|
$resume_data['reparser']++;
|
||||||
|
|
Loading…
Add table
Reference in a new issue