Editing a Markdown file in a public share fails: TextContextProviderFactory::__construct(): Argument #5 ($userId) must be of type string, null given

Aberta Para iniciantes
#8,729 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
76/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
php

Direção de pesquisa

Comece por lib/Provider/TextContextProviderFactory.php e lib/Provider/TextContextProvider.php; em seguida, verifique como PermissionService lida com um ID de usuário null. Adicione um teste de regressão em tests/unit/Provider/TextContextProviderFactoryTest.php para a construção da factory com null e verifique se build() e buildForCard() retornam contextos válidos. O trabalho estará concluído quando a edição de compartilhamentos públicos não falhar mais com esse TypeError e o teste de regressão passar.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

0. Needs triage bug

Summary

After upgrading Nextcloud (35.0.2.2), editing a Markdown file in a public share fails with a 500 error. Deck's TextContextProviderFactory is resolved by the Text app for every registered text context, and on public shares there is no logged-in user, so the DI container injects null into the non-nullable string $userId constructor parameter.
Steps to reproduce

Create a public share link for a Markdown (.md) file
Open the share and start editing the file
The sync request POST /index.php/apps/text/public/session/<id>/sync fails

Error

OCA\Deck\Provider\TextContextProviderFactory::__construct(): Argument #5 ($userId) must be of type string, null given
in /nextcloud/apps/deck/lib/Provider/TextContextProviderFactory.php line 20

Relevant trace: OCA\Text\Controller\PublicSessionController::sync → ApiService::getContext → ContextManager::getContexts → dispatchTyped(RegisterContextEvent) → ServiceEventListener → SimpleContainer::resolve(TextContextProviderFactory::class) → TypeError.

Expected behavior
Editing a Markdown file in a public share works; Deck's context factory must not crash when no user is logged in.

Proposed solution
Widen the constructor parameter to nullable in both classes, since the downstream consumer already accepts null:

lib/Provider/TextContextProviderFactory.php:25: string $userId → ?string $userId
lib/Provider/TextContextProvider.php:34: string $userId → ?string $userId

PermissionService::checkPermission(..., $userId = null) (lib/Service/PermissionService.php:172) and userCan()/userIsBoardOwner() already handle null, so with no user the context simply resolves to read-only instead of throwing a TypeError. A regression test (tests/unit/Provider/TextContextProviderFactoryTest.php) constructs the factory with null userId and asserts build()/buildForCard() still return a valid context.

Environment
Nextcloud 35.0.2.2, Deck current master, Text app public share session

Linguagem predominante
JavaScript
Estrelas
1.4k
Forks
363
Merge médio
1d 5h
PRs com merge (30d)
118

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de nextcloud/deck

Todas as issues de nextcloud/deck

Issues semelhantes

Mais issues de JavaScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.