Skip to content

Commit ee8403a

Browse files
committed
fix: clear appconfig cache in reverse-cookie self-test
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent d491a50 commit ee8403a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/Controller/TestController.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use OCP\AppFramework\Controller;
1616
use OCP\AppFramework\Http\DataDisplayResponse;
1717
use OCP\AppFramework\Http\DataResponse;
18+
use OCP\IAppConfig;
1819
use OCP\IConfig;
1920
use OCP\IRequest;
2021

@@ -25,7 +26,7 @@ class TestController extends Controller {
2526

2627
public function __construct(
2728
IRequest $request,
28-
IConfig $config,
29+
IAppConfig $config,
2930
IQueue $queue,
3031
IAppManager $appManager,
3132
) {
@@ -41,7 +42,14 @@ public function __construct(
4142
* @NoCSRFRequired
4243
*/
4344
public function cookie(): DataResponse {
44-
return new DataResponse((int)$this->config->getAppValue('notify_push', 'cookie', '0'));
45+
// starting with 32, the app config does some internal caching
46+
// that interferes with the quick set+get from this test.
47+
// unfortunately the api to clear the cache is 29+ only, and we still support 27
48+
if (method_exists($this->config, 'clearCache')) {
49+
/** @psalm-suppress UndefinedInterfaceMethod */
50+
$this->config->clearCache();
51+
}
52+
return new DataResponse((int)$this->config->getValue('notify_push', 'cookie', '0'));
4553
}
4654

4755
/**

lib/SelfTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use OCA\NotifyPush\Queue\RedisQueue;
1414
use OCP\App\IAppManager;
1515
use OCP\Http\Client\IClientService;
16+
use OCP\IAppConfig;
1617
use OCP\IConfig;
1718
use OCP\IDBConnection;
1819
use Symfony\Component\Console\Output\OutputInterface;
@@ -28,6 +29,7 @@ class SelfTest {
2829
public function __construct(
2930
IClientService $clientService,
3031
private IConfig $config,
32+
private IAppConfig $appConfig,
3133
private IQueue $queue,
3234
private IDBConnection $connection,
3335
private IAppManager $appManager,
@@ -55,7 +57,7 @@ public function test(string $server, OutputInterface $output, bool $ignoreProxyE
5557
}
5658

5759
$this->queue->push('notify_test_cookie', $this->cookie);
58-
$this->config->setAppValue('notify_push', 'cookie', (string)$this->cookie);
60+
$this->appConfig->setValue('notify_push', 'cookie', (string)$this->cookie);
5961

6062
try {
6163
$retrievedCookie = (int)$this->client->get($server . '/test/cookie', ['nextcloud' => ['allow_local_address' => true], 'verify' => false])->getBody();

0 commit comments

Comments
 (0)