Admin UI: disabling the birthday calendar for an address book returns 500 (FK violation on calendarchanges)

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

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
82/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
mysql, php, symfony
Domínio
backend, database

Direção de pesquisa

Leia src/Services/BirthdayService.php perto de deleteBirthdayCalendar() e compare a limpeza com CalendarController::calendarDelete nas linhas 276–284. Reproduza desativando os calendários de aniversário para um catálogo de endereços que tenha uma entrada de aniversário e, em seguida, verifique como os objetos de calendário relacionados e as alterações são removidos antes de excluir o calendário. O trabalho estará concluído quando o catálogo de endereços for salvo com sucesso e o calendário de aniversário for removido sem um erro de chave estrangeira.

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

Descrição

Davis version

v5.6.3

Installation method

Docker – standalone (with Caddy)

Database

MariaDB

Reverse proxy

Traefik

Authentication method

Internal (ADMIN_LOGIN / ADMIN_PASSWORD)

Affected protocol(s)
  • Admin dashboard
Client(s) exhibiting the issue

Admin dashboard in the browser

Relevant environment variables
APP_ENV=prod
CALDAV_ENABLED=true
CARDDAV_ENABLED=true
WEBDAV_ENABLED=false
PUBLIC_CALENDARS_ENABLED=false
APP_KEYS_ENABLED=true
DATABASE_DRIVER=mysql
BIRTHDAY_REMINDER_OFFSET=PT8H30M
AUTH_METHOD unset
Steps to reproduce
  1. Set "Include in birthday calendar" to Yes on a user's address book that contains a card with a BDAY, so the birthday calendar is created and gets at least one row in calendarchanges
  2. Edit the same address book, set "Include in birthday calendar" to No, save
  3. → 500
Expected behaviour

The address book is saved and the birthday calendar is removed, since no address book of the user is included anymore.

Actual behaviour

500 Internal Server Error. The address book change itself is saved (it is flushed before the sync), but the birthday calendar stays, and every later save of that address book returns 500 again.

Logs
request.INFO: Matched route "addressbook_edit". {"route":"addressbook_edit", ... "request_uri":"https://<host>/addressbooks/1/edit/1","method":"POST"}
request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException: "An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`davis`.`calendarchanges`, CONSTRAINT `FK_737547E2B8CB7204` FOREIGN KEY (`calendarid`) REFERENCES `calendars` (`id`))" at ExceptionConverter.php line 58
Additional context

After the save, AddressBookController::addressbookCreate calls BirthdayService::syncUser(). When no address book is included anymore, syncPrincipal() calls deleteBirthdayCalendar() (BirthdayService.php#L130-L145), which removes the instance and the calendar but not the calendar's rows in calendarchanges (or calendarobjects), so the FK rejects the delete. main has the same code.

CalendarController::calendarDelete already removes objects and changes before the calendar (CalendarController.php#L276-L284), so doing the same in deleteBirthdayCalendar() should fix it.

Possibly related to #328 (enabling the birthday calendar returns 500), but the cause here is a different one.

Linguagem predominante
PHP
Estrelas
769
Forks
45
Merge médio
2d 9h
PRs com merge (30d)
4

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

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 tchapi/davis

Todas as issues de tchapi/davis

Issues semelhantes

Mais issues de PHP

Receba novas issues na sua caixa de entrada

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