Skip to content

Commit 009d6f7

Browse files
fix(RowService): allow public share row operations without breaking async import guard
ef3db38 tightened the userId guard in RowService::create() and ::updateSet() from `=== null` to `=== null || === ''` to prevent async import background jobs from silently creating rows without a real user in context. However, the codebase intentionally uses an empty string as the public-context sentinel: PublicRowOCSController calls setPublicContext(), which sets $this->userId = '' in SuperService and $isPublicContext = true in PermissionsService. PermissionsService::basisCheck() explicitly handles $userId === '' by returning true when isPublicContext is set. The tightened guard in ef3db38 rejected '' before it ever reached the permissions layer, breaking row create and update for all public link shares. The fix tracks the public context flag in SuperService itself via a new $isPublicContext property, set alongside $this->userId = '' in setPublicContext(). The guard in RowService is updated to: null → always throws (DI never injected a user) '' + !publicCtx → throws (background job running without a user — the case ef3db38 was protecting against) '' + publicCtx → passes (setPublicContext() was called intentionally) 'alice' → always passes (normal authenticated user) Async imports remain protected because ImportTableJob never calls setPublicContext(), so $isPublicContext stays false for that code path. AI-assistant: Claude Code v2.1.143 (Claude Sonnet 4.6) Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent 025dcc2 commit 009d6f7

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

lib/Service/RowService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function create(?int $tableId, ?int $viewId, RowDataInput|array $data, ?s
182182
if ($userId) {
183183
$this->userId = $userId;
184184
}
185-
if ($this->userId === null || $this->userId === '') {
185+
if ($this->userId === null || ($this->userId === '' && !$this->isPublicContext)) {
186186
$e = new \Exception('No user id in context, but needed.');
187187
$this->logger->error($e->getMessage(), ['exception' => $e]);
188188
throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': ' . $e->getMessage());
@@ -571,7 +571,7 @@ public function updateSet(
571571
if ($userId) {
572572
$this->userId = $userId;
573573
}
574-
if ($this->userId === null || $this->userId === '') {
574+
if ($this->userId === null || ($this->userId === '' && !$this->isPublicContext)) {
575575
$e = new \Exception('No user id in context, but needed.');
576576
$this->logger->error($e->getMessage(), ['exception' => $e]);
577577
throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': ' . $e->getMessage());

lib/Service/SuperService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class SuperService {
1616

1717
protected ?string $userId;
1818

19+
protected bool $isPublicContext = false;
20+
1921
public function __construct(LoggerInterface $logger, ?string $userId, PermissionsService $permissionsService) {
2022
$this->permissionsService = $permissionsService;
2123
$this->logger = $logger;
@@ -24,6 +26,7 @@ public function __construct(LoggerInterface $logger, ?string $userId, Permission
2426

2527
public function setPublicContext(): void {
2628
$this->userId = '';
29+
$this->isPublicContext = true;
2730
$this->permissionsService->setPublicContext();
2831
}
2932
}

0 commit comments

Comments
 (0)