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

[CachedReader] Test traits and parent class to see if cache is fresh #62

Closed
wants to merge 1 commit into from

Conversation

iamluc
Copy link
Contributor

@iamluc iamluc commented Sep 10, 2015

This PR is useful if for exemple you work with traits in your entities or with a parent class.
Before, the cache was not refreshed when you made changes in traits or parent class.

@iamluc iamluc changed the title Test traits and parent class to see if cache is fresh [CachedReader] Test traits and parent class to see if cache is fresh Sep 10, 2015
@curry684
Copy link

curry684 commented Jun 25, 2016

This PR probably fixes an issue I've been having with Symfony. Our workflow includes generating the mapping into a separate trait, so it can be regenerated when needed without hitting business functionality. For example:

/*
 * @ORM\Entity
 */
class MyEntity
{
    use Generated\MyEntityTrait;
}

And the trait:

trait MyEntityTrait
{
    /**
     * @ORM\Column(type="string", length=255)
     */
    private $slug;
}

Running doctrine:schema:update does not detect any changes when I change the length property or make it nullable. It does pick it up if:

  • $slug is renamed or anything else is modified in the trait
  • Anything, including annotations, is changed in the class itself

While digging into this I ran into this PR which likely fixes it. Any timeline on merging?

@mikeSimonson
Copy link
Contributor

@Ocramius This seems good to go to me.
Maybe just adding a test case with a parent class that has a trait.

@shochdoerfer
Copy link

Any chance the change can be merged in soonish? Hitting the same problem with bitexpert/disco when using traits to split up the DI config into smaller components.

@Ocramius Ocramius self-assigned this Oct 22, 2016
@Ocramius Ocramius added this to the v1.3.0 milestone Oct 22, 2016
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will apply review comments myself while merging.

$lastModification = filemtime($filename);

// Test traits
if (method_exists($class, 'getTraits')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be moved to a private method

}

// Test parents
while ($parent = $class->getParentClass()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be moved to a private method


public function testIgnoresStaleCacheWithTraits()
{
if (version_compare(PHP_VERSION, '5.4.0') < 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't support these versions anymore, luckily.

@Ocramius
Copy link
Member

Moved rest of the PR to #96

@Ocramius Ocramius closed this Oct 24, 2016
Ocramius added a commit that referenced this pull request Oct 24, 2016
Ocramius added a commit that referenced this pull request Oct 24, 2016
Ocramius added a commit that referenced this pull request Oct 24, 2016
…lass-ttl-in-annotations

Fix/#62 check trait and parent class ttl in annotations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants