Skip to content

PHPORM-264: Deprecate Mongo soft deletes trait #3408

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

Open
wants to merge 1 commit into
base: 5.x
Choose a base branch
from

Conversation

paulinevos
Copy link
Collaborator

In favor of the Laravel one. Ours is now obsolete; the SoftDeletes trait is only necessary to remove the call to qualifyColumn in the parent trait. But the DocumentModel::qualifyColumn is already disabled.

Also replaces some internal/test usages with the recommended trait.

Closes PHPORM-264

Checklist

  • Ensure tests still pass
In favor of the Laravel one. Ours is now obsolete; the SoftDeletes trait
is only necessary to remove the call to qualifyColumn in the parent
trait. But the DocumentModel::qualifyColumn is already disabled
@paulinevos paulinevos requested review from a team as code owners June 16, 2025 13:18
@paulinevos paulinevos requested review from rustagir and GromNaN June 16, 2025 13:18
@github-actions github-actions bot added the docs label Jun 16, 2025
@paulinevos paulinevos enabled auto-merge (squash) June 16, 2025 13:23
Copy link
Contributor

@rustagir rustagir left a comment

Choose a reason for hiding this comment

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

changes to docs tests lgtm

@@ -4,6 +4,7 @@

namespace MongoDB\Laravel\Eloquent;

/** @deprecated 6.0.0 in favor of \Illuminate\Database\Eloquent\SoftDeletes */
Copy link
Member

@GromNaN GromNaN Jun 23, 2025

Choose a reason for hiding this comment

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

We can trigger a deprecation when the PHP file is loaded.

In the @deprecated annotation, we usually give the version of the deprecation.

Suggested change
/** @deprecated 6.0.0 in favor of \Illuminate\Database\Eloquent\SoftDeletes */
trigger_error(sprintf('Since mongodb/laravel-mongodb:5.5, trait "%s" is deprecated, use "%s" instead.', SoftDeletes::class, \Illuminate\Database\Eloquent\SoftDeletes::class), E_USER_DEPRECATED);
/** @deprecated since mongodb/laravel-mongodb:5.5, use \Illuminate\Database\Eloquent\SoftDeletes instead */

Example of an other deprecation I put in the library:

* @deprecated since mongodb/laravel-mongodb:5.2, use getDatabase() instead
*
* @return Database
*/
public function getMongoDB()
{
trigger_error(sprintf('Since mongodb/laravel-mongodb:5.2, Method "%s()" is deprecated, use "getDatabase()" instead.', __FUNCTION__), E_USER_DEPRECATED);

An other example of deprecating a class in Symfony: https://github.com/symfony/symfony/blob/138109a63e2202674d81f31481da7c6defe4c0ce/src/Symfony/Component/Serializer/CacheWarmer/CompiledClassMetadataCacheWarmer.php#L19

@paulinevos paulinevos requested a review from GromNaN June 25, 2025 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 participants