Comments (6)
@janklan 2.0.1
has just been released, including your fixes, thanks!
from auditor.
@DamienHarper I found another related issue that I fixed in the associated PR - after adding the missing $id
, one relationship worked fine, but one did not. I don't know enough about Auditor's internals, so I did not track why, but https://github.com/DamienHarper/auditor/blob/master/src/Provider/Doctrine/Auditing/Transaction/TransactionHydrator.php#L102 does not supply the entity ID.
Effectively there are two incompatible disassociation events, one with the ID, one without. I assume the with is the right scenario?
Neither issues were picked up by the test suite.
Also I don't mean to tell you how to do things, but I've had extremely bad experience relying on arrays as data objects passing data around.
Why not use a DTO class with specified properties, data types etc?
So not,
[
$collection->getOwner(),
$entity,
$this->id($entityManager, $entity),
$mapping,
]
rather
new DisassociationEvent($collection->getOwner(), $entity, $this->id($entityManager, $entity), $mapping);
In a perfect world, this would look like
class DisassociationEvent(public readonly object $source, public readonly object $target, public readonly mixed $id, public readonly array $mapping) {}
Clearly with the need to support older PHP, the actual class would be more verbose, but something like this would let static code analysers pick up errors of this kind - unlike when using vague arrays?
The auditor is an awesome tool, thank you for your work.
from auditor.
@janklan Thanks for that clear report and the associated PR, much appreciated.
You're right regarding DTO vs basic arrays, it has to be changed. Feel free to submit a PR if you want to, I'd be glad to merge it.
from auditor.
Thanks, it's great to see some quick action!
from auditor.
@DamienHarper I tried to work out why didn't the test suite fail even though the coverage was there. It turns out the failing code is not really being covered - I'm not quite sure how would the listed test cases cover the problematic line:
Sure enough, when you only run php -d pcov.enabled=1 ./vendor/bin/phpunit --filter=TransactionProcessorTest::testDissociateManyToMany
, none of the lines are covered:
I tried to extend the test case to actually employ TransactionHydrator
to populate a real Transaction
object that could then be passed to the TransactionProcessor
to trip the error, but quite frankly, my understanding of Doctrine internals is not good enough to get it done. I failed to make the UoW object report any removals from the Post::$tags collection.
If you could push me in the right direction, I'm happy to help out by adding a more complete test suite, and then swap the arrays to DTO classes. I don't dare to touch the code if it's not reliably covered. I'm concerned I could blow up other people's projects.
from auditor.
@janklan #93 brings better coverage
from auditor.
Related Issues (20)
- Add whitelist option to audit columns HOT 2
- Incorrect primary key name on render HOT 2
- Deprecation of Doctrine\DBAL\Logging\SQLLogger Interface HOT 3
- Linking changes in child entities to their parent entity HOT 1
- BackedEnum could not be converted to int HOT 1
- Json column is double encoded HOT 3
- exception while creating audit table schema when using single table inheritance HOT 8
- Laravel support HOT 1
- Error on upgrading symfony 6.2 HOT 20
- Breaking Change in PR#137 HOT 1
- Attempted to call an undefined method named "introspectSchema" of class "Doctrine\DBAL\Schema\PostgreSQLSchemaManager" HOT 1
- How to define a storage mapper? HOT 4
- Deprecation spam HOT 11
- UTF-8 Character Encoding fails in TransactionProcessor HOT 1
- 2.4.4 broke enum compatibility HOT 2
- Laminas Framework HOT 1
- Warning: mb_convert_encoding(): Object is not supported HOT 2
- Make DoctrineODM / MongoDB compatible?
- Custom columns and custom data in the audit tables
- Example use statement shown for Auditing Configuration in Docs Undefined HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auditor.