Fixed getUpgradeTitlePairs returns in consistent value type

Affected version
2.1.8 PL2

TickTackk

Well-known member
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);
    }
 

XF Bug Bot

XenForo bug fixer bot
Staff member
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