Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache not updated when entity annotation is changed #2644

Closed
alexandresalome opened this issue Mar 25, 2019 · 12 comments
Closed

Cache not updated when entity annotation is changed #2644

alexandresalome opened this issue Mar 25, 2019 · 12 comments
Assignees

Comments

@alexandresalome
Copy link

This morning, I started a new project with API Platform v2.4, and almost from scratch, I had to clear the cache to get my API documentation updated.

Steps to reproduce

Create a new Symfony application api-platform-issue symfony new --full api-platform-issue.

Go to this new project (cd api-platform-issue).

Install API platform by using composer req api.

Install embedded web server composer req server and start it bin/console server:run.

Open API doc: http://localhost:8000/api

Create an entity Pizza:

<?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ApiResource
 * @ORM\Entity
 */
class Pizza
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     *
     * @var int
     */
    private $id;

    public function getId(): ?int
    {
        return $this->id;
    }
}

Refresh your API doc, you don't see any change.

Delete your cache (rm -rf var/cache).

API is updated.

Further steps

If you delete the annotation and update cache, you'll see no change.

Environment details

Bug reproduced:

  • With a docker environment (PHP 7.3)
  • With my local PHP setup (PHP 7.2)
@dunglas
Copy link
Member

dunglas commented Mar 25, 2019

Probably related to #2629... @teohhanhui can you take a look? Maybe should we revert this patch until it is properly tested and "edge cases" (this one is a basic case) are handled properly.

@soyuka
Copy link
Member

soyuka commented Mar 25, 2019

This is even more related to #2593 and it's not easy to take a decision that will not have an impact.

@dunglas
Copy link
Member

dunglas commented Mar 25, 2019

I prefer to favor DX than performance in dev env.

@teohhanhui
Copy link
Contributor

teohhanhui commented Mar 25, 2019

Symfony uses cache in dev environment out of the box. We should do the same. If we require more manual cache:clear, then that's something we should fix.

@bastnic
Copy link
Contributor

bastnic commented Mar 25, 2019

So we are back at square 1 with a lot of things to improve performance as it's so poor right now it's a also DX problem.

@teohhanhui
Copy link
Contributor

@bastnic Unfortunately, yeah...

@soyuka
Copy link
Member

soyuka commented Mar 25, 2019

About this case you can still use metadata_cache=true in your configuration but yeah...

@dunglas
Copy link
Member

dunglas commented Mar 25, 2019

@bastnic in the meantime you can set api_platform.metadata_cache to true if you don't mind running cache:clear manually. But I'm sure there are rooms for improvements that doesn't hurt DX.

@bastnic
Copy link
Contributor

bastnic commented Mar 25, 2019

If I remember correctly, the main issues are:

  • parsing to get which property is the identifier
  • reconstruct all the routing on each requests
  • that there is no static cache whatsoever when it's disabled and so we do all these heavy operations again and again.

@teohhanhui
Copy link
Contributor

I'll look into it.

@teohhanhui
Copy link
Contributor

Closing as it's been reverted in #2648, but I'll look into #2644 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants