1. This area is dedicated to the support of our xF2 add-ons, for support of our xF1 add-ons please use the dedicated forums.
    Note that we only accept support question and bug reports in this section.

    For suggestions, please wait until xF2 stable is released as we'll reorganize our forum at that time and accept them.
Dismiss Notice
We have just posted about our product policy for XF2.
Click HERE to view it.

Media Of The Month MOTM album creation bug

Discussion in 'Add-Ons Support' started by MtoR, Nov 2, 2018.

  1. MtoR

    MtoR Freaky Coder
    Staff Member

    Joined:
    Nov 14, 2015
    Messages:
    4,626
    Likes Received:
    726
    Error on 4.0.5 (and probably 4.0.6 as well as the code causing the error seems to be identical in both versions):


    Code:
    
    InvalidArgumentException: Attempted to convert NULL to string/binary [username] in src/XF/Mvc/Entity/Entity.php:691
    
    
    #0 src/XF/Mvc/Entity/Entity.php(575): XF\Mvc\Entity\Entity->_castValueToType(NULL, 'username', 5, Array)
    
    #1 src/XF/Mvc/Entity/Entity.php(505): XF\Mvc\Entity\Entity->set('username', NULL)
    
    #2 src/addons/XFMG/Service/Album/Creator.php(52): XF\Mvc\Entity\Entity->__set('username', NULL)
    
    #3 src/addons/XFMG/Service/Album/Creator.php(43): XFMG\Service\Album\Creator->setUser(Object(XFMG\XF\Entity\User))
    
    #4 src/addons/XFMG/Service/Album/Creator.php(34): XFMG\Service\Album\Creator->setAlbum()
    
    #5 src/XF/Container.php(273): XFMG\Service\Album\Creator->__construct(Object(XF\Pub\App))
    
    #6 src/XF/App.php(1359): XF\Container->createObject('XFA\\XFMGMediaOf...', Array)
    
    #7 src/XF/Container.php(228): XF\App->XF\{closure}('XFA\\XFMGMediaOf...', Array, Object(XF\Container))
    
    #8 src/XF/App.php(2508): XF\Container->create('service', 'XFMG\\Service\\Al...', Array)
    
    #9 src/addons/XFA/XFMGMediaOfTheMonth/Service/Album/Create.php(51): XF\App->service('XFMG\\Service\\Al...')
    
    #10 src/addons/XFA/XFMGMediaOfTheMonth/Cron/XFMGMediaOfTheMonth.php(172): XFA\XFMGMediaOfTheMonth\Service\Album\Create->create()
    
    #11 src/addons/XFA/XFMGMediaOfTheMonth/Cron/XFMGMediaOfTheMonth.php(19): XFA\XFMGMediaOfTheMonth\Cron\XFMGMediaOfTheMonth::cronMode1()
    
    #12 [internal function]: XFA\XFMGMediaOfTheMonth\Cron\XFMGMediaOfTheMonth::cron(Object(XF\Entity\CronEntry))
    
    #13 src/XF/Job/Cron.php(35): call_user_func(Array, Object(XF\Entity\CronEntry))
    
    #14 src/XF/Job/Manager.php(241): XF\Job\Cron->run(8)
    
    #15 src/XF/Job/Manager.php(187): XF\Job\Manager->runJobInternal(Array, 8)
    
    #16 src/XF/Job/Manager.php(76): XF\Job\Manager->runJobEntry(Array, 8)
    
    #17 job.php(14): XF\Job\Manager->runQueue(false, 8)
    
    #18 {main}
    
    

    This happens when a guest triggers the creation of an album:

    The Album Creator Service ([icode]\XFMG\Service\Album\Creator[/icode]) implicitly calls [icode]$this->setAlbum()[/icode] in its constructor which then calls
    PHP:
    $this->setUser(\XF::visitor())
    which finally tries to set the username on the entitiy, but guests do not have a username.


    To prevent this, [icode]XFA\XFMGMediaOfTheMonth\Service\Album\Creator::create()[/icode] needs to wrap the entitiy manger call in [icode]\XF::asVisitor()[/icode]


    This is actually pretty much the same issue as https://xenforo.com/community/threads/xfa-media-of-the-month-xf2-paid.151970/post-1293110 - this also happend (it should not happen with 4.0.6 due to [icode]\XF::asVisitor[/icode]) because a guest triggered the cronjob and the thread replier service implicitly set the user to [icode]\XF::visitor()[/icode] (and used that further down) in its constructor.
     
  2. JayT

    JayT Member

    Joined:
    Jun 25, 2016
    Messages:
    101
    Likes Received:
    2
    Is this error going to be fixed? This is now the third month the add-on has failed to start an album for me. At some point my license will expire without a single contest starting.
     
  3. MtoR

    MtoR Freaky Coder
    Staff Member

    Joined:
    Nov 14, 2015
    Messages:
    4,626
    Likes Received:
    726
    Yes for sure, I am going to fix it this weekend.
    I am sorry for the inconvenience, as I was manually running the cron in my tests I never came in front of that bug.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice