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

Remove the remaining soft deleteable code #4767

Merged

Conversation

coudenysj
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? ?
Deprecations? yes
Related tickets fixes #4761 and #4461
License MIT

TODO

@@ -46,10 +46,8 @@ public function indexByCustomerAction(Request $request, $id)

// Fetch and cache deleted orders
$entityManager = $this->container->get('doctrine.orm.entity_manager');
Copy link
Contributor

Choose a reason for hiding this comment

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

$entityManager is not needed anymore, as well as comment above.

@coudenysj
Copy link
Contributor Author

Looks like TravisCI is having a lot of difficulties?

@Zales0123
Copy link
Member

@coudenysj yes, sadly it seems to fail with latest chrome version. All should be fixed after merging #4786.

@coudenysj
Copy link
Contributor Author

As far as I can tell, the soft deleteable magic is not tested in any Behat feature file.

We have to wait on #4786 to see if anything breaks, I guess.

@coudenysj coudenysj changed the title [WIP] Remove the remaining soft deleteable code Remove the remaining soft deleteable code Apr 15, 2016
@michalmarcinkowski
Copy link
Contributor

@coudenysj #4786 was merged, please rebase.

@coudenysj coudenysj force-pushed the bugfix/4761-remove-softdeleteable branch from 55b151e to 8fe1dbf Compare April 18, 2016 07:48
@coudenysj
Copy link
Contributor Author

@michalmarcinkowski Done!

@michalmarcinkowski michalmarcinkowski merged commit 8be8407 into Sylius:master Apr 18, 2016
@michalmarcinkowski
Copy link
Contributor

michalmarcinkowski commented Apr 18, 2016

Great job! Thanks Jachim! 👍

@pjedrzejewski
Copy link
Member

Awesome work Jachim, thank you so much!

@rvanlaak
Copy link
Contributor

rvanlaak commented May 24, 2016

Great! Thanks, the softdeleteable also resulted into errors when the promotion bundle was used stand-alone. Can we let userland just enable it before and disable it after we use CouponGenerator::generateUniqueCode?

@pjedrzejewski
Copy link
Member

@rvanlaak I am not sure what you mean? Soft-deleteable behavior is gone from Sylius.

@rvanlaak
Copy link
Contributor

@pjedrzejewski yes I know, but I'm still on 0.17 and the change was merged after that release. So basically my question is whether, until another version is released, I can just enable it before and disable the filter afterwards?

Oh wait, I see 0.18 is released yesterday. Think I'm going to upgrade right away. Major breaks on promotion?

@rvanlaak
Copy link
Contributor

The upgrade to 0.18 wasn't easy, got a missing factory error while compiling the container. Probably has something to do with a missing dependency if promotion is used stand-alone.

@michalmarcinkowski
Copy link
Contributor

@rvanlaak did you resolve this issue?

@rvanlaak
Copy link
Contributor

@michalmarcinkowski no we postponed the upgrade for now, but will try again soon. Did hope that the documentation on the upgrade can be improved, given 0.18 has that many changes related to the promotion component: https://github.com/Sylius/Sylius/blob/master/CHANGELOG.md

@rvanlaak
Copy link
Contributor

We updated from 0.17 to 0.19 today, basically rewriting the softDelete functionality took us quite some time. We are fine with removing it from the Promotion entity, but we ourselves actually have a use-case for it on the Coupon entity. When customers bought a coupon from us but don't want to use it anymore, we should be able to "delete" it.

@michalmarcinkowski are there any plans to simulate the softDelete behaviour for the Coupon entity, but without using the DoctrineExtensions? The only thing about the decision proces I can find on it is you saying that is should be removed in #4761 (comment), but I'm not exactly sure why :)

@coudenysj coudenysj deleted the bugfix/4761-remove-softdeleteable branch October 17, 2016 08:03
@coudenysj
Copy link
Contributor Author

@rvanlaak I think a solution could be to use the ToggleableInterface.

@michalmarcinkowski
Copy link
Contributor

@rvanlaak if coupon is not used you should be able to delete it, if it was already used it should be archived. See #4140 and our idea for archiving.

@michalmarcinkowski
Copy link
Contributor

Btw. for coupons you can simply set "expiresAt" to make it archived :)

@rvanlaak
Copy link
Contributor

Ah thanks for referencing #4140, I agree with the problem statement given there 👍 For now I was able to reuse the deletedAt field that already exists by overriding the Coupon class used by the promotion component:

/**
 * @ORM\Table(name="sylius_promotion_coupon")
 * @ORM\Entity
 *
 * @Gedmo\SoftDeleteable(fieldName="deletedAt")
 */
class Coupon extends BaseCoupon
{
    use SoftDeleteableEntity;
}

After the first alpha is released we will migrate it to expiresAt. Wouldn't it be better to "improve" the ToggleableTrait and use an expiresAt datetime instead of the boolean that is used now? The bool doesn't tell us anything about the coupon's history (read: archive date).

@michalmarcinkowski
Copy link
Contributor

Not sure what do you mean? PromotionCoupon is not toggleable.

@rvanlaak
Copy link
Contributor

Yes that's correct, so I'd like to propose to make PromotionCoupon toggleable and would like to know if you agree on that too.

The second thing I'd like to mention (aside of making it toggleable itself), is that it would be great if ToggleableTrait::$enabled could become a DateTime to provide more info about the lifecycle of the entity. In other words: so we can see when the coupon was archived. That would also make archiving in the future possible:

/**
 * @return Boolean
 */
public function isEnabled()
{
    if (null !== $this->enabled) {
        return $this->enabled <= (new \DateTime());
    }

    return false;
}

@michalmarcinkowski
Copy link
Contributor

That seems redundant. Why not simply use expiresAt for this? The logic is already implemented and working.

@rvanlaak
Copy link
Contributor

Okay thanks 👍 For our use-case the archiving has a different use-case than the expiresAt field would have so I'll stick with my custom implementation for now.

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.

What is the status of the SoftDeleteableFilter?
5 participants