Skip to content

Commit 469ca2a

Browse files
Merge pull request #508 from nextcloud/backport/506/stable31
[stable31] fix: ensure that Crawler does not run if no internet connection is disabled
2 parents 9e5fd3f + 67fdbdd commit 469ca2a

1 file changed

Lines changed: 13 additions & 20 deletions

File tree

lib/Cron/Crawler.php

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,25 @@
1818
use OCP\IUser;
1919
use OCP\Notification\IManager as INotificationManager;
2020
use phpseclib\File\X509;
21+
use Psr\Log\LoggerInterface;
2122

2223
class Crawler extends TimedJob {
2324
public const FEED_URL = 'https://pushfeed.nextcloud.com/feed';
2425

25-
/** @var string */
26-
protected $appName;
27-
/** @var IConfig */
28-
protected $config;
29-
/** @var IGroupManager */
30-
protected $groupManager;
31-
/** @var INotificationManager */
32-
protected $notificationManager;
33-
/** @var IClientService */
34-
protected $clientService;
3526

3627
/** @var array<array-key, bool> */
3728
protected $notifyUsers = [];
3829

39-
public function __construct(string $appName,
30+
public function __construct(
4031
ITimeFactory $time,
41-
IConfig $config,
42-
IGroupManager $groupManager,
43-
INotificationManager $notificationManager,
44-
IClientService $clientService) {
32+
protected string $appName,
33+
protected IConfig $config,
34+
protected IGroupManager $groupManager,
35+
protected INotificationManager $notificationManager,
36+
protected IClientService $clientService,
37+
protected LoggerInterface $logger,
38+
) {
4539
parent::__construct($time);
46-
$this->appName = $appName;
47-
$this->config = $config;
48-
$this->groupManager = $groupManager;
49-
$this->notificationManager = $notificationManager;
50-
$this->clientService = $clientService;
5140

5241
// Run once per day
5342
$interval = 24 * 60 * 60;
@@ -61,6 +50,10 @@ public function __construct(string $appName,
6150

6251

6352
protected function run(mixed $argument): void {
53+
if ($this->config->getSystemValueBool('has_internet_connection', true) === false) {
54+
$this->logger->info('This instance does not have Internet connection to access the Nextcloud feed platform.', ['app' => $this->appName]);
55+
return;
56+
}
6457
try {
6558
$feedBody = $this->loadFeed();
6659
$rss = simplexml_load_string($feedBody);

0 commit comments

Comments
 (0)