pronamic / wp-pronamic-pay

The Pronamic Pay plugin allows you to easily accept payments with payment methods like credit card, iDEAL, Bancontact and Sofort through a variety of payment providers on your WordPress website.
https://pronamicpay.com
34 stars 14 forks source link

Remove meta through `AbstractDataStoreCPT::update_meta()`? #283

Open rvdsteege opened 2 years ago

rvdsteege commented 2 years ago

In the subscriptions data store, the $subscription->get_next_payment_date() can result in a null value (e.g. when a phase has a fixed number of periods and the last period has been reached). Updating the meta value with $this->update_meta( $id, 'next_payment', $subscription->get_next_payment_date() ) leaves the meta value unaffected, because there's an empty value check in https://github.com/pronamic/wp-pay-core/blob/3303f7f200796405e74b27f65a0965bad6fe5a77/src/AbstractDataStoreCPT.php#L228-L230

I've now added an explicit check for the null value to delete the post meta:

Question: Should the AbstractDataStoreCPT::update_meta() method also be able to remove post meta if the new value is null?