DoctrineExtensions icon indicating copy to clipboard operation
DoctrineExtensions copied to clipboard

[Loggable] Allow composite identifiers

Open MisatoTremor opened this issue 4 years ago • 30 comments

Composite identifiers with foreign entities

New version of #2128 as of main branch rename

MisatoTremor avatar Oct 06 '20 19:10 MisatoTremor

Could this possibly be merged? IMHO it is an important feature to add support for composite identifiers.

rotdrop avatar Feb 17 '21 00:02 rotdrop

Rebased and fixed PHP and XML code style

MisatoTremor avatar Oct 21 '21 11:10 MisatoTremor

Well, finally adopted the changed test namespaces.

@phansys Could you give me a heads up, where this breaks BC, please? Maybe this can be changed

MisatoTremor avatar Nov 15 '21 03:11 MisatoTremor

@phansys Could you give me a heads up, where this breaks BC, please? Maybe this can be changed

Sure: https://github.com/doctrine-extensions/DoctrineExtensions/pull/2171#discussion_r749102248.

phansys avatar Nov 15 '21 08:11 phansys

Resolved conflicts and code style

@phansys Could you please verify this no longer breaks BC?

MisatoTremor avatar Nov 24 '21 11:11 MisatoTremor

@phansys Could you please verify this no longer breaks BC?

I think the current changes respect BC, thank you :+1:

phansys avatar Nov 24 '21 14:11 phansys

Resolved all requests

MisatoTremor avatar Nov 24 '21 16:11 MisatoTremor

@phansys Hopefully I catched all missing type hints and imports. The PHPStan error seems to be unrelated to this PR

MisatoTremor avatar Nov 26 '21 23:11 MisatoTremor

BTW, I think the changelog section should include an Added entry, as this is a new feature.

phansys avatar Nov 27 '21 01:11 phansys

You are right of course, doesn't make sense to not mention it 😅

MisatoTremor avatar Nov 27 '21 02:11 MisatoTremor

Codecov Report

Merging #2171 (3ac4c85) into main (0a97af5) will decrease coverage by 0.73%. The diff coverage is 89.74%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #2171      +/-   ##
============================================
- Coverage     80.97%   80.24%   -0.74%     
- Complexity     3119     3121       +2     
============================================
  Files           153      153              
  Lines          8038     8007      -31     
============================================
- Hits           6509     6425      -84     
- Misses         1529     1582      +53     
Impacted Files Coverage Δ
src/References/Mapping/Driver/Xml.php 0.00% <0.00%> (ø)
src/Loggable/Mapping/Driver/Annotation.php 77.77% <50.00%> (ø)
src/Loggable/Mapping/Driver/Yaml.php 62.71% <50.00%> (ø)
src/Loggable/LoggableListener.php 94.16% <75.00%> (ø)
...oggable/Document/Repository/LogEntryRepository.php 95.23% <100.00%> (+0.07%) :arrow_up:
.../Loggable/Entity/Repository/LogEntryRepository.php 96.61% <100.00%> (ø)
src/Loggable/Mapping/Driver/Xml.php 83.33% <100.00%> (ø)
src/Loggable/Mapping/Event/Adapter/ORM.php 100.00% <100.00%> (ø)
src/Tool/Wrapper/EntityWrapper.php 100.00% <100.00%> (+2.32%) :arrow_up:
src/Tool/Wrapper/MongoDocumentWrapper.php 88.63% <100.00%> (ø)
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0a97af5...3ac4c85. Read the comment docs.

codecov-commenter avatar Dec 05 '21 22:12 codecov-commenter

Resolved conflicts.

Could you please give me a heads up why my changes might remove coverage here @phansys? Or should I ignore that?

MisatoTremor avatar Dec 05 '21 23:12 MisatoTremor

Could you please give me a heads up why my changes might remove coverage here @phansys? Or should I ignore that?

I think it is due the way Codecov makes the comparison with the parent commit. I guess the coverage report will be more accurate after a rebasing and squashing the commits in this PR. I'd sat you can ignore this warning by now. BTW, please note that the PR still has conflicts.

phansys avatar Dec 06 '21 12:12 phansys

@phansys Thank you for your answer.

I can't see any conflicts, though.

MisatoTremor avatar Dec 07 '21 20:12 MisatoTremor

I can't see any conflicts, though.

Don't you see this message?

This branch cannot be rebased due to conflicts

image

phansys avatar Dec 07 '21 20:12 phansys

Nope, I get this Screenshot 2021-12-07 at 21 32 06

MisatoTremor avatar Dec 07 '21 20:12 MisatoTremor

I get conflicts when I try to rebase, though. Still weird, but I will do this now

MisatoTremor avatar Dec 07 '21 20:12 MisatoTremor

OK done @phansys. Just wanted to ask if you could also check that I did not reintroduce some of the old issues?

MisatoTremor avatar Dec 07 '21 21:12 MisatoTremor

OK done @phansys. Just wanted to ask if you could also check that I did not reintroduce some of the old issues?

I'm not aware about the related issues, as I'm not using this extension. If you have in mind some previous issues related to these changes, please try to add tests covering the issues with a clear reference to them.

phansys avatar Dec 07 '21 21:12 phansys

@phansys I was just referring to the issues you pointed out in your reviews. To make sure I did not reintroduce one of them while rebasing.

MisatoTremor avatar Dec 08 '21 10:12 MisatoTremor

@phansys I was just referring to the issues you pointed out in your reviews. To make sure I did not reintroduce one of them while rebasing.

Oh, don't worry about that then :+1:

phansys avatar Dec 09 '21 13:12 phansys

Hi, thanks for the PR!

Just a couple of comments, looking at the method calls ->getIdentifier(false, true) seems a little bit weird to me and the way the ids are flattened (return implode(' ', $id);) seems like it should belong somewhere else to me.

So what about making getIdentifier return always an array (deprecating passing true) like the one from ClassMetadata and also extracting the "flattener" to a class so it could be used somewhere else.

franmomu avatar Dec 11 '21 22:12 franmomu

I'm open to that @franmomu of course. But it might be out of scope for this PR as it would need changes all over DoctrineExtensions. So maybe it warrants a prerequisite PR for itself.

But would leave that decision up to you maintainers before starting work on it.

MisatoTremor avatar Dec 12 '21 20:12 MisatoTremor

So what about making getIdentifier return always an array (deprecating passing true) like the one from ClassMetadata and also extracting the "flattener" to a class so it could be used somewhere else.

The flattener should probably kept in sync with

https://github.com/doctrine/orm/blob/536b65f02b853cc9c8bfb184d23a4cc4feecf002/lib/Doctrine/ORM/Utility/IdentifierFlattener.php#L15-L20

which actually just does what Steffen does. Or perhaps use the IdentifierFlattener from ORM instead of coding the same thing again?

I'm still trying to find time to post a corresponding pull request for Translatable, and other things ... it would be nice, if this PR could finally be merged.

rotdrop avatar Feb 04 '22 23:02 rotdrop

@rotdrop I remember using IdentifierFlattener during initial development of this, which did not work at the time, but that may have change since then ...

@phansys Could you please have another look at this? I am currently lost as how to prevent the deprecation reports by PHPUnit which lead to the failed tests. Also I have no idea why the PHPStan error in Geo.php suddenly appears.

MisatoTremor avatar Jun 14 '22 19:06 MisatoTremor

I am currently lost as how to prevent the deprecation reports by PHPUnit which lead to the failed tests.

I guess you should add the new $flatten argument in the existing calls to WrapperInterface::getIdentifier().

Also I have no idea why the PHPStan error in Geo.php suddenly appears.

I'll try to take a look at this.

phansys avatar Jun 14 '22 20:06 phansys

Also I have no idea why the PHPStan error in Geo.php suddenly appears.

Regarding this, I think we could safely remove that ignored error from the baseline (see https://phpstan.org/r/b92f2814-4530-4cda-aaf4-236c6c3eaadf).

https://github.com/doctrine-extensions/DoctrineExtensions/blob/118a001c1d0855df5c9ee35c1588d80a4d517d97/phpstan-baseline.neon#L808-L812

phansys avatar Jun 14 '22 20:06 phansys

I guess you should add the new $flatten argument in the existing calls to WrapperInterface::getIdentifier().

The calls were not the problem, but the classes implementing the interface, only adding the second parameter there resolved the error. Changing the interface was also not necessary.

Regarding this, I think we could safely remove that ignored error from the baseline (see https://phpstan.org/r/b92f2814-4530-4cda-aaf4-236c6c3eaadf).

Done. Thank you!

MisatoTremor avatar Jun 15 '22 10:06 MisatoTremor

@phansys And another error which I think is unrelated. My guess would it to be a hiccup on GitHubs end. Can you please re-run the failed jobs as I can't do that here. It ran successful local.

MisatoTremor avatar Jun 15 '22 11:06 MisatoTremor

The issues reported by PHPStan should be resolved by #2475.

phansys avatar Jun 20 '22 02:06 phansys