Skip to content

Conversation

@IonBazan
Copy link
Member

@IonBazan IonBazan commented Dec 5, 2025

Q A
Type improvement
BC Break yes
Fixed issues -

Summary

Removes some features marked as deprecated:

  • fsync, safe and w write concerns
  • indexes attribute property
  • LegacyReflectionFields support
  • NOTIFY change tracking policy support
  • Combining targetDocument with discriminatorMap will now trigger exception.
  • Passing an array to setDiscriminatorField

@IonBazan IonBazan added this to the 3.0.0 milestone Dec 5, 2025
Copilot finished reviewing on behalf of IonBazan December 5, 2025 13:21
@IonBazan IonBazan force-pushed the drop-deprecated branch 2 times, most recently from da7be12 to eb94490 Compare December 5, 2025 13:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes several deprecated features from the MongoDB ODM 3.x branch as part of a breaking change cleanup:

  • Deprecated write concern options (fsync, safe, w)
  • LegacyReflectionFields support in favor of PropertyAccessors
  • NOTIFY change tracking policy support
  • indexes attribute property in document annotations
  • Combination of targetDocument with discriminatorMap (now throws exception)

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/UnitOfWork.php Removed deprecated write concern options handling and NOTIFY change tracking logic
src/Persisters/DocumentPersister.php Removed deprecated write concern option handling from write options
src/PersistentCollection/PersistentCollectionTrait.php Removed NOTIFY change tracking support and needsSchedulingForSynchronization() method
src/Mapping/LegacyReflectionFields.php Deleted entire legacy reflection fields implementation
src/Mapping/Driver/AttributeDriver.php Removed handling of deprecated indexes attribute property
src/Mapping/ClassMetadataFactory.php Removed deprecation warning for NOTIFY change tracking policy
src/Mapping/ClassMetadata.php Removed LegacyReflectionFields properties and methods; changed targetDocument + discriminatorMap from deprecation to exception
src/Mapping/MappingException.php Added new exception method for targetDocument + discriminatorMap combination
src/Mapping/Annotations/File.php Removed deprecated indexes parameter from File annotation
src/Mapping/Annotations/EmbeddedDocument.php Removed deprecated indexes parameter and constructor from EmbeddedDocument annotation
src/Configuration.php Removed deprecated write concern options validation from configuration
tests/Tests/Mapping/LegacyReflectionFieldsTest.php Deleted test file for removed LegacyReflectionFields feature
tests/Tests/Mapping/ClassMetadataTest.php Removed assertion checking for LegacyReflectionFields instance
Comments suppressed due to low confidence (1)

src/PersistentCollection/PersistentCollectionTrait.php:741

  • The needsSchedulingForSynchronization() method is being removed, but it's still referenced in DefaultPersistentCollectionGenerator::generateMethod() at line 199. This will cause a fatal error when generated persistent collection classes try to call this non-existent method. The generator code should also be updated to remove the call to this method.
    /**
     * @phpstan-param Closure(TKey, T):bool $p
     *
     * @phpstan-return T|null
     */
    public function findFirst(Closure $p): ?object

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

$metadata->addLifecycleCallback('doStuffOnPrePersist', 'prePersist');
$metadata->addLifecycleCallback('doOtherStuffOnPrePersistToo', 'prePersist');
$metadata->addLifecycleCallback('doStuffOnPostPersist', 'postPersist');
$metadata->setDiscriminatorField(['fieldName' => 'discr']);
Copy link
Member Author

Choose a reason for hiding this comment

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

I found that this loadMetadata() method is not even called - all tests were passing without TypeError thrown, when I left it like that.

Perhaps we can remove this method completely.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it can be removed here and from the 2.x branch.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can leave it for now and try to cover it with a different test.

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

Successfully merging this pull request may close these issues.

2 participants