From 1526455be31606cf6d9007010efb1a19fcfc2b1f Mon Sep 17 00:00:00 2001 From: DariusIII Date: Mon, 28 Jan 2019 14:12:42 +0100 Subject: [PATCH] Fix safe backfill --- Blacklight/libraries/Forking.php | 4 ++-- Changelog | 1 + misc/update/multiprocessing/.do_not_run/switch.php | 14 ++++++++++++-- misc/update/multiprocessing/backfill.php | 2 ++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Blacklight/libraries/Forking.php b/Blacklight/libraries/Forking.php index 970ee0393..099bc5472 100755 --- a/Blacklight/libraries/Forking.php +++ b/Blacklight/libraries/Forking.php @@ -385,7 +385,7 @@ class Forking extends \fork_daemon $backfill_qty = (int) Settings::settingValue('site.tmux.backfill_qty'); $backfill_order = (int) Settings::settingValue('site.tmux.backfill_order'); $backfill_days = (int) Settings::settingValue('site.tmux.backfill_days'); - $maxmssgs = (int) Settings::settingValue('maxmssgs'); + $maxmssgs = (int) Settings::settingValue('..maxmssgs'); $threads = (int) Settings::settingValue('..backfillthreads'); $orderby = 'ORDER BY a.last_record ASC'; @@ -414,7 +414,7 @@ class Forking extends \fork_daemon $backfilldays = ''; if ($backfill_days === 1) { $days = 'backfill_target'; - $backfilldays = now()->subDays((int) $days)->format('Y-m-d'); + $backfilldays = now()->subDays(Carbon::createFromDate($days)); } elseif ($backfill_days === 2) { $backfilldays = now()->subDays(Carbon::createFromFormat('Y-m-d', Settings::settingValue('..safebackfilldate'))->diffInDays())->format('Y-m-d'); } diff --git a/Changelog b/Changelog index 623303fc5..2d5a899b3 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2019-01-28 DariusIII + * Fix: Fix safe backfill * Chg: Make settingValue function silent for undefined index * Fix: Fix check for not empty collections table in Forking class * Chg: Update composer/ca-bundle (1.1.3 => 1.1.4) diff --git a/misc/update/multiprocessing/.do_not_run/switch.php b/misc/update/multiprocessing/.do_not_run/switch.php index c6d9097a9..d0e35a31a 100644 --- a/misc/update/multiprocessing/.do_not_run/switch.php +++ b/misc/update/multiprocessing/.do_not_run/switch.php @@ -16,6 +16,7 @@ use Blacklight\Binaries; use Blacklight\Nfo; use Blacklight\NNTP; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; // Are we coming from python or php ? $options[0] => (string): python|php // The type of process we want to do: $options[1] => (string): releases @@ -28,16 +29,18 @@ switch ($options[1]) { // $options[3] => (int) backfill type from tmux settings. 1 = Backfill interval , 2 = Bakfill all case 'backfill': if (in_array((int)$options[3], [1, 2], false)) { - $value = Settings::settingValue('site.tmux.backfill_qty'); - if ($value !== false) { + $value = (int) Settings::settingValue('site.tmux.backfill_qty'); + if ($value !== null) { try { $nntp = nntp(); } catch (Exception $e) { + Log::error($e->getTraceAsString()); echo $e->getMessage(); } try { (new Backfill())->backfillAllGroups($options[2], ($options[3] === 1 ? '' : $value['value'])); } catch (Exception $e) { + Log::error($e->getTraceAsString()); echo $e->getMessage(); } } @@ -53,11 +56,13 @@ switch ($options[1]) { try { $nntp = nntp(); } catch (Exception $e) { + Log::error($e->getTraceAsString()); echo $e->getMessage(); } try { (new Backfill())->backfillAllGroups($options[2], $options[3]); } catch (Exception $e) { + Log::error($e->getTraceAsString()); echo $e->getMessage(); } break; @@ -68,11 +73,13 @@ switch ($options[1]) { try { $nntp = nntp(); } catch (Exception $e) { + Log::error($e->getTraceAsString()); echo $e->getMessage(); } try { (new Backfill())->backfillAllGroups($options[2], 10000, 'normal'); } catch (Exception $e) { + Log::error($e->getTraceAsString()); echo $e->getMessage(); } break; @@ -97,16 +104,19 @@ switch ($options[1]) { return; } } catch (Exception $e) { + Log::error($e->getTraceAsString()); echo $e->getMessage(); } try { $binaries = new Binaries(['NNTP' => $nntp, 'Groups' => null]); } catch (Exception $e) { + Log::error($e->getTraceAsString()); echo $e->getMessage(); } try { $return = $binaries->scan($groupMySQL, $options[4], $options[5], ((int) Settings::settingValue('..safepartrepair') === 1 ? 'update' : 'backfill')); } catch (Exception $e) { + Log::error($e->getTraceAsString()); echo $e->getMessage(); } if (empty($return)) { diff --git a/misc/update/multiprocessing/backfill.php b/misc/update/multiprocessing/backfill.php index a17a72024..82cf40264 100644 --- a/misc/update/multiprocessing/backfill.php +++ b/misc/update/multiprocessing/backfill.php @@ -3,10 +3,12 @@ declare(ticks=1); require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use Blacklight\libraries\Forking; +use Illuminate\Support\Facades\Log; // Check if argument 1 is numeric, which is to limit article count. try { (new Forking())->processWorkType('backfill', (isset($argv[1]) && is_numeric($argv[1]) && $argv[1] > 0 ? [0 => $argv[1]] : [0 => false])); } catch (Exception $e) { + Log::error($e->getTraceAsString()); echo $e->getMessage(); }