From aae4696a103d7aba274202170defe92d93c96ad0 Mon Sep 17 00:00:00 2001 From: "Simon L." Date: Tue, 29 Jul 2025 11:26:43 +0200 Subject: [PATCH 1/2] fix: ensure that Crawler does not run if no internet connection is disabled Signed-off-by: Simon L. --- lib/Cron/Crawler.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Cron/Crawler.php b/lib/Cron/Crawler.php index 1f30e09b..1825681f 100644 --- a/lib/Cron/Crawler.php +++ b/lib/Cron/Crawler.php @@ -61,6 +61,10 @@ public function __construct(string $appName, protected function run(mixed $argument): void { + if ($this->config->getSystemValueBool('has_internet_connection', true) === false) { + \OC::$server->getLogger()->info('This instance does not have Internet connection to access the Nextcloud feed platform.', ['app' => $this->appName]); + return; + } try { $feedBody = $this->loadFeed(); $rss = simplexml_load_string($feedBody); From 67fdbdde1b39c813ead8385c6803f9c32c9095d2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 29 Jul 2025 13:57:37 +0200 Subject: [PATCH 2/2] fix(job): Don't use deprecated way to get logger Signed-off-by: Joas Schilling --- lib/Cron/Crawler.php | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/lib/Cron/Crawler.php b/lib/Cron/Crawler.php index 1825681f..49ee0261 100644 --- a/lib/Cron/Crawler.php +++ b/lib/Cron/Crawler.php @@ -18,36 +18,25 @@ use OCP\IUser; use OCP\Notification\IManager as INotificationManager; use phpseclib\File\X509; +use Psr\Log\LoggerInterface; class Crawler extends TimedJob { public const FEED_URL = 'https://pushfeed.nextcloud.com/feed'; - /** @var string */ - protected $appName; - /** @var IConfig */ - protected $config; - /** @var IGroupManager */ - protected $groupManager; - /** @var INotificationManager */ - protected $notificationManager; - /** @var IClientService */ - protected $clientService; /** @var array */ protected $notifyUsers = []; - public function __construct(string $appName, + public function __construct( ITimeFactory $time, - IConfig $config, - IGroupManager $groupManager, - INotificationManager $notificationManager, - IClientService $clientService) { + protected string $appName, + protected IConfig $config, + protected IGroupManager $groupManager, + protected INotificationManager $notificationManager, + protected IClientService $clientService, + protected LoggerInterface $logger, + ) { parent::__construct($time); - $this->appName = $appName; - $this->config = $config; - $this->groupManager = $groupManager; - $this->notificationManager = $notificationManager; - $this->clientService = $clientService; // Run once per day $interval = 24 * 60 * 60; @@ -62,7 +51,7 @@ public function __construct(string $appName, protected function run(mixed $argument): void { if ($this->config->getSystemValueBool('has_internet_connection', true) === false) { - \OC::$server->getLogger()->info('This instance does not have Internet connection to access the Nextcloud feed platform.', ['app' => $this->appName]); + $this->logger->info('This instance does not have Internet connection to access the Nextcloud feed platform.', ['app' => $this->appName]); return; } try {