Won't fix Default value of AbstractProvider::ERR_NO_RECURRING never set

Jon W

Well-known member
Affected version
2.1.0
In XF\Payment\AbstractProvider, there is a method with the following signature:
public function supportsRecurring(PaymentProfile $paymentProfile, $unit, $amount, &$result = self::ERR_NO_RECURRING)

However, it only ever seems to be called by a method in XF\Entity\PaymentProfile with the following signature:
public function supportsRecurring($unit, $amount, &$result = null)

So the default value of self::ERR_NO_RECURRING seems a bit pointless as I always have to explicitly set $result, even if my payment provider doesn't support recurring payments.
 
While I agree with you to an extent, we can't really change the method signature now as that would break any existing implementations. Your comments also assume that supportsRecurring will always be called from the PaymentProfile entity. It's possible that it could be called directly on the payment provider object in which case the default value would be self::ERR_NO_RECURRING if it isn't set anywhere else.

I don't think this actually causes any problems so it's not really worth fixing.
 
To avoid breaking things, you could add something like:
PHP:
if ($result === null) {
    $result = \XF\Payment\AbstractProvider::ERR_NO_RECURRING;
}
to the top of the PaymentProfile entity method.

Rather than assuming that it will always be called from that method, I guess I am just suggesting that it is always going to be a possibility, hence you can never really rely on the default value, even if other methods that called it did respect it.

It's no big deal though. I guess I was just surprised when I realised that that was why my code wasn't working as I can usually rely on these things.
 
Back
Top Bottom