Fixed getUpgradeTitlePairs returns in consistent value type

TickTackk

Well-known member
Affected version
2.1.8 PL2
PHP:
    public function getUpgradeTitlePairs()
    {
        return $this->findUserUpgradesForList()->fetch()->pluck(function($e, $k)
        {
            return [$k, $e->title];
        });
    }
That returns an generic array if there is any user upgrade.

But if there are no user upgrades then it will return ArrayCollection. The only place where it returns consistent value type is in XF:Payment repository by passing additional argument false for $collectionOnEmpty:
PHP:
    public function getPaymentProfileTitlePairs()
    {
        return $this->findPaymentProfilesForList()
            ->fetch()
            ->pluck(function(\XF\Entity\PaymentProfile $profile)
            {
                return [
                    $profile->payment_profile_id,
                    $profile->display_title ?: $profile->title
                ];
            }, false);
    }
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.1.10).

Change log:
Ensure arrays are always returned from title pair methods
There may be a delay before changes are rolled out to the XenForo Community.
 
Top Bottom