Question Shop & XFA custom username icon issue

Status
Not open for further replies.

madness85

Customer
Hi,

Got an issue with these addons running together. Every page load gives me an error:

  • TypeError: Template public:widget_forum_statistics error: json_decode(): Argument #1 ($json) must be of type string, array given
  • src/XF/Mvc/Entity/ValueFormatter.php:33

Code:
#0 src/XF/Mvc/Entity/ValueFormatter.php(33): json_decode(Array, true)
#1 src/XF/Mvc/Entity/ValueFormatter.php(64): XF\Mvc\Entity\ValueFormatter->decodeValueFromSource(65552, Array)
#2 src/XF/Mvc/Entity/Manager.php(794): XF\Mvc\Entity\ValueFormatter->decodeValueFromSourceExtended(65552, Array, Array)
#3 src/XF/Mvc/Entity/Entity.php(237): XF\Mvc\Entity\Manager->decodeValueFromSourceExtended(65552, Array, Array)
#4 src/XF/Mvc/Entity/Entity.php(183): XF\Mvc\Entity\Entity->getValue('dbtech_shop_pur...')
#5 src/addons/XFA/CustomUsernameIcons/XF/Entity/User.php(18): XF\Mvc\Entity\Entity->get('dbtech_shop_pur...')
#6 src/XF/Mvc/Entity/Entity.php(112): XFA\CustomUsernameIcons\XF\Entity\User->get('dbtech_shop_pur...')
#7 src/addons/DBTech/Shop/XF/Entity/User.php(219): XF\Mvc\Entity\Entity->__get('dbtech_shop_pur...')
#8 src/XF/Mvc/Entity/Entity.php(160): DBTech\Shop\XF\Entity\User->getDbtechShopPurchase()
#9 src/addons/XFA/CustomUsernameIcons/XF/Entity/User.php(18): XF\Mvc\Entity\Entity->get('dbtech_shop_pur...')
#10 src/XF/Mvc/Entity/Entity.php(112): XFA\CustomUsernameIcons\XF\Entity\User->get('dbtech_shop_pur...')
#11 src/addons/DBTech/Shop/Repository/Purchase.php(296): XF\Mvc\Entity\Entity->__get('dbtech_shop_pur...')
#12 src/addons/DBTech/Shop/Repository/Purchase.php(331): DBTech\Shop\Repository\Purchase->getViewablePurchasesForUser(Object(XFA\CustomUsernameIcons\XF\Entity\User), false)
#13 src/addons/DBTech/Shop/XF/Entity/User.php(286): DBTech\Shop\Repository\Purchase->filterActivePurchasesForUser(Object(XFA\CustomUsernameIcons\XF\Entity\User), false)
#14 src/addons/XFA/CustomUsernameIcons/XF/Entity/User.php(38): DBTech\Shop\XF\Entity\User->hasPermission('xfa_cui', 'selectCustomIco...')
#15 src/addons/XFA/CustomUsernameIcons/XF/Template/Templater.php(87): XFA\CustomUsernameIcons\XF\Entity\User->canXfaSelectCustomUsernameIcon()
#16 src/XF/Template/Templater.php(1128): XFA\CustomUsernameIcons\XF\Template\Templater->fnUsernameLink(Object(XFA\CustomUsernameIcons\XF\Template\Templater), false, Object(XFA\CustomUsernameIcons\XF\Entity\User), false, Array)
#17 internal_data/code_cache/templates/l1/s13/public/widget_forum_statistics.php(28): XF\Template\Templater->func('username_link', Array)
#18 src/XF/Template/Templater.php(1651): XF\Template\Templater->{closure}(Object(XFA\CustomUsernameIcons\XF\Template\Templater), Array, NULL)
#19 src/XF/Widget/WidgetRenderer.php(62): XF\Template\Templater->renderTemplate('widget_forum_st...', Array)
#20 src/XF/Widget/WidgetRenderer.php(67): XF\Widget\WidgetRenderer->render()
#21 src/XF/Template/Templater.php(1928): XF\Widget\WidgetRenderer->__toString()
#22 internal_data/code_cache/templates/l1/s13/public/forum_list.php(216): XF\Template\Templater->widgetPosition('forum_list_side...', Array)
#23 src/XF/Template/Templater.php(1651): XF\Template\Templater->{closure}(Object(XFA\CustomUsernameIcons\XF\Template\Templater), Array, NULL)
#24 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('forum_list', Array)
#25 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render()
#26 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XF:Forum\\Listin...', 'public:forum_li...', Array)
#27 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#28 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#29 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#30 src/XF/App.php(2352): XF\Mvc\Dispatcher->run()
#31 src/XF.php(524): XF\App->run()
#32 index.php(20): XF::runApp('XF\\Pub\\App')
#33 {main}
 
Can you show me the contents of src/addons/XFA/CustomUsernameIcons/XF/Entity/User.php?
Code:
<?php
/*************************************************************************
 * XenForo Custom Username Icons - Xen Factory (c) 2017
 * All Rights Reserved.
 * Created by Clement Letonnelier aka. MtoR
 *************************************************************************
 * This file is subject to the terms and conditions defined in the Licence
 * Agreement available at http://xen-factory.com/pages/license-agreement/.
 *************************************************************************/

namespace XFA\CustomUsernameIcons\XF\Entity;

class User extends XFCP_User
{
    /* Tweak to allow smooth upgrade from FA 4 to FA5 if no fas/far/fab/fal prefix is present */
    public function get($key)
    {
        $data = parent::get($key);

        if ($key == "xfa_cui_params")
        {
            if(isset($data[0]['icon']) && ($data[0]['type'] == 'fa') && !in_array(substr($data[0]['icon'], 0, 3), ['fab','far','fas','fal']))
            {
                $data['icon'] = 'fas ' . $data['icon'];
            }
        }

        return $data;
    }

    public function getMaximumUsernameIcons()
    {
        return $this->hasPermission('xfa_cui', 'maxIcons') ? $this->hasPermission('xfa_cui', 'maxIcons') : 1;
    }

    public function canXfaSelectCustomUsernameIcon()
    {
        return ($this->hasPermission('xfa_cui', 'selectCustomIcon')
            && !$this->xfa_cui_forced);
    }

    public function canXfaSelectCustomUsernameIconColor()
    {
        return ($this->hasPermission('xfa_cui', 'selectColor')
            && !$this->xfa_cui_forced);
    }

    public function canXfaSelectCustomUsernameIconTransformation()
    {
        return ($this->hasPermission('xfa_cui', 'selectIconTransformation')
            && !$this->xfa_cui_forced);
    }

    public function canXfaSelectCustomUsernameIconAnimation()
    {
        return ($this->hasPermission('xfa_cui', 'selectIconAnimation')
            && !$this->xfa_cui_forced);
    }

    public function canXfaSelectUserNameColor()
    {
        return $this->hasPermission('xfa_cui', 'selectUsernameColor');
    }

    public function canXfaSelectUserTitleColor()
    {
        return $this->hasPermission('xfa_cui', 'selectUsertitleColor');
    }

    public function canXfaDisableCustomUsernameIconsAnimations()
    {
        return $this->hasPermission('xfa_cui', 'canDisableAnimations');
    }
}
 
Try removing the entire get function from that file. If it's a recent install, you shouldn't need it, and it's the only one I can see being problematic.
 
Try removing the entire get function from that file. If it's a recent install, you shouldn't need it, and it's the only one I can see being problematic.
Code:
/*     public function get($key)
    {
        $data = parent::get($key);

        if ($key == "xfa_cui_params")
        {
            if(isset($data[0]['icon']) && ($data[0]['type'] == 'fa') && !in_array(substr($data[0]['icon'], 0, 3), ['fab','far','fas','fal']))
            {
                $data['icon'] = 'fas ' . $data['icon'];
            }
        }

        return $data;
    }
    */

Like that ^^ if so it didn't do anything. Would you say this is defiantly a CustomUsername issue then?
 
It's hard to tell - when looking at the code, I can't see why it would cause an issue, but if removing that bit of code fixes the issue for you, it's likely that it is the culprit.

If the XFA developer disagrees and needs me to make a change in my code, I'd be happy to do so :)
 
It's hard to tell - when looking at the code, I can't see why it would cause an issue, but if removing that bit of code fixes the issue for you, it's likely that it is the culprit.

If the XFA developer disagrees and needs me to make a change in my code, I'd be happy to do so :)
It didn't stop the error. I will try talk to XFA and get back to you.
 
@Fillip H. Just been doing some more testing and if I uninstall/install the shop again the error is gone. Does this mean I must have previous version code remaining?

I can't reproduce the error on a fresh xenforo install.
 
Status
Not open for further replies.

DragonByte Shop

XenForo 1.5.3+ XenForo 2.0.x XenForo 2.1.x XenForo 2.2.x
Seller
DragonByte Technologies
Release date
Last update
Total downloads
3,203
Customer rating
5.00 star(s) 3 ratings
Back
Top