Как отладить ошибку 500 при удалении в Symfony 3.4 - PullRequest
0 голосов
/ 29 января 2020

Я получаю 500 ошибок в коде ниже

/**
 * @Operation(
 *     tags={"User"},
 *     summary="Remove account",
 *     @SWG\Response(
 *         response="200",
 *         description="Returned when successful"
 *     )
 * )
 * @Rest\Put("/removeAccount")
 * @return JsonResponse
 * @throws \Exception If something critical happened.
 */
public function removeAccount()
{
    /** @var User $user */
    $user = $this->getUser();

    $em = $this->getDoctrine()->getManager();

    $em->remove($user);

    $em->flush();

    return JsonResponse::create([
        'code' => JsonResponse::HTTP_OK,
        'message' => 'Account has been deleted',
    ]);
}

Нет ничего в prod.log / dev.log или php_errors.log

Любые идеи о том, как я могу отладить это?

1 Ответ

1 голос
/ 29 января 2020

Вы должны выйти из системы, удалив ее из token_storage:

/**
 * @Operation(
 *     tags={"User"},
 *     summary="Remove account",
 *     @SWG\Response(
 *         response="200",
 *         description="Returned when successful"
 *     )
 * )
 * @Rest\Put("/removeAccount")
 * @return JsonResponse
 * @throws \Exception If something critical happened.
 */
public function removeAccount()
{
    /** @var User $user */
    $user = $this->getUser();

    $this->get('security.token_storage')->setToken(null);

    $em = $this->getDoctrine()->getManager();

    $em->remove($user);

    $em->flush();

    return JsonResponse::create([
        'code' => JsonResponse::HTTP_OK,
        'message' => 'Account has been deleted',
    ]);
}
...