[XFA] Media Of The Month - XF2

[XFA] Media Of The Month - XF2 [Paid] 4.1.3

No permission to buy (€15.00)

Kirby

Well-known member
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 (\XFMG\Service\Album\Creator) implicitly calls $this->setAlbum() 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, XFA\XFMGMediaOfTheMonth\Service\Album\Creator::create() needs to wrap the entitiy manger call in \XF::asVisitor()

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 \XF::asVisitor) because a guest triggered the cronjob and the thread replier service implicitly set the user to \XF::visitor() (and used that further down) in its constructor.
 
Last edited:

XFA

Formerly MtoR
Indeed, I'll have to go though the different calls to xF services to check if there are no other calls like that.
Thanks for reporting.
 

ichpen

Well-known member
Indeed, I'll have to go though the different calls to xF services to check if there are no other calls like that.
Thanks for reporting.
I think that's exactly what's been happening in my case which explains why crons were failing and manual runs were succeeding. Let me know when you have a properly patched version out.

Thanks.
 

ichpen

Well-known member
Another bug,

Winner Thread message parameter {2} (user link) appears to be resolving to the thread poster and not the actual owner of the awarded media {3}. For example I have admin that posts all user submission posts and the award message said that admin user won the contest with the media being another user's.

Also multiple MOTM pics do not show in the MOTM widget, only shows one item.

EDIT: OK, something very weird happened. I reset start date to today and ran manually. I got 2 additional MOTM awards (with incorrect message) for Nov in my original October thread but it did create a new Nov contest thread.... It is now showing multiple MOTM pics in the widget but the Oct message was totally messed up.
 

XFA

Formerly MtoR
Winner Thread message parameter {2} (user link) appears to be resolving to the thread poster and not the actual owner of the awarded media {3}. For example I have admin that posts all user submission posts and the award message said that admin user won the contest with the media being another user's.
Hum. That's odd this is something I had tested, perhaps my test config was incorrect.

Also multiple MOTM pics do not show in the MOTM widget, only shows one item.
In options of the widget, you set it to show more than 1 ?

EDIT: OK, something very weird happened. I reset start date to today and ran manually. I got 2 additional MOTM awards (with incorrect message) for Nov in my original October thread but it did create a new Nov contest thread.... It is now showing multiple MOTM pics in the widget but the Oct message was totally messed up.
In which mode ? Anyways, in your previous automated run, it most certainly created the contest so running it manually at a later date in the month while one exist could lead to unexpected results.
 

ichpen

Well-known member
Hum. That's odd this is something I had tested, perhaps my test config was incorrect.



In options of the widget, you set it to show more than 1 ?



In which mode ? Anyways, in your previous automated run, it most certainly created the contest so running it manually at a later date in the month while one exist could lead to unexpected results.
Yes please check the award message parameters. They are definitely not right (author param 2 particularly).

As for the weirdness that was mode 2 and yes I did run it manually as it was broken (it didn't award and did not create a Nov thread). Please understand that this has never worked properly for 3 months now as you very well know, I'm not running it manually just for the fun of it so would appreciate a bit more assistance and more detail than unexpected results.

I don't so much care about October now as that's passed but I do have a Nov thread and voted media submissions is going in there for now. Is that expected to work correctly from now on? After the manual run I just reset the start date to the 1st (so it closes on Dec 1). Appreciate insights as I'm on the verge of ditching this given my users are a little bit confused about the contest that never was.

Sorry about the attitude but I'm a wee bit annoyed that I have to yet again spend time trying to address this addon.
 

XFA

Formerly MtoR
Yes please check the award message parameters. They are definitely not right (author param 2 particularly).
Looked at the code, I think I know why.
Will be releasing a bug fix version either tomorrow or the day after.

As for the weirdness that was mode 2 and yes I did run it manually as it was broken (it didn't award and did not create a Nov thread). Please understand that this has never worked properly for 3 months now as you very well know, I'm not running it manually just for the fun of it so would appreciate a bit more assistance and more detail than unexpected results.
I said unexpected results because I can't exactly detail like that what it would do wrong, I just now it will.

I don't so much care about October now as that's passed but I do have a Nov thread and voted media submissions is going in there for now. Is that expected to work correctly from now on? After the manual run I just reset the start date to the 1st (so it closes on Dec 1). Appreciate insights as I'm on the verge of ditching this given my users are a little bit confused about the contest that never was.

Sorry about the attitude but I'm a wee bit annoyed that I have to yet again spend time trying to address this addon.
No problem, sorry about the inconvenience.
But as I test alone the add-on and have to manually run the cron as I can't wait a month for it to run there are things I may have not came across unfortunately.

Changing date after running manually should be ok for nov.

Clément
 
Last edited:

ichpen

Well-known member
Last edited:

XFA

Formerly MtoR
I confirm the behaviour, I used the suggested code without checking the subsequent posts behaviour.
I will release a bug fix version.

What will basically happen after this upgrade is that next post will trigger the thread creation and all the consecutive posts will go there instead of the multiple threads right now.
 
Write now there is a time to add media and time to add vote (Default 7)

Is it possible to enable media add from day one and voting same time. So adding media and voting starts day 1 and ends in end of month.
 

XFA

Formerly MtoR
Write now there is a time to add media and time to add vote (Default 7)

Is it possible to enable media add from day one and voting same time. So adding media and voting starts day 1 and ends in end of month.
Right now it's not implemented no.
 

XFA

Formerly MtoR
Ok, i already purchased this addon and didn't notice that :(

Is it possible to add this option? Or do you have a time to make custom work?
You can request that feature on our forum.
I can't tell you when it'll be implemented though.
 

ichpen

Well-known member
Using latest MOTM and Core 1.5.5 I found these two errors this morning:

@XFA

  • ErrorException: [E_NOTICE] Trying to get property 'last_post_date' of non-object
  • src/addons/XFA/XFMGMediaOfTheMonth/Service/Motm/ThreadNotifier.php:192
  • Generated by: 12cents
  • Jan 18, 2019 at 9:55 PM
Stack trace
#0 src/addons/XFA/XFMGMediaOfTheMonth/Service/Motm/ThreadNotifier.php(192): XF::handlePhpError(8, '[E_NOTICE] Tryi...', '/home/nginx/dom...', 192, Array)
#1 src/addons/XFA/XFMGMediaOfTheMonth/Service/Media/Voter.php(78): XFA\XFMGMediaOfTheMonth\Service\Motm\ThreadNotifier->notify()
#2 src/addons/XFA/XFMGMediaOfTheMonth/XFMG/Pub/Controller/Media.php(49): XFA\XFMGMediaOfTheMonth\Service\Media\Voter->vote()
#3 src/XF/Mvc/Dispatcher.php(249): XFA\XFMGMediaOfTheMonth\XFMG\Pub\Controller\Media->actionVoteMotm(Object(XF\Mvc\ParameterBag))
#4 src/XF/Mvc/Dispatcher.php(88): XF\Mvc\Dispatcher->dispatchClass('XFMG:Media', 'VoteMotm', 'html', Object(XF\Mvc\ParameterBag), 'xfmg', Object(XFA\XFMGMediaOfTheMonth\XFMG\Pub\Controller\Media), NULL)
#5 src/XF/Mvc/Dispatcher.php(41): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#6 src/XF/App.php(1934): XF\Mvc\Dispatcher->run()
#7 src/XF.php(333): XF\App->run()
#8 index.php(13): XF::runApp('XF\\Pub\\App')
#9 {main}

Request state
array(4) {
["url"] => string(30) "/media/82-vette.1328/vote-motm"
["referrer"] => string(55) "https://site.com/media/82-vette.1328/"
["_GET"] => array(1) {
["/media/82-vette_1328/vote-motm"] => string(0) ""
}
["_POST"] => array(1) {
["_xfToken"] => string(8) "****"
}
}


  • TypeError: Argument 2 passed to XF\Service\Thread\Replier::__construct() must be an instance of XF\Entity\Thread, null given, called in /home/nginx/domains/site.com/public/src/XF/Container.php on line 274
  • src/XF/Service/Thread/Replier.php:35
  • Generated by: CCF VetteBot
  • Jan 18, 2019 at 9:55 PM
Stack trace
#0 src/XF/Container.php(274): XF\Service\Thread\Replier->__construct(Object(XF\Pub\App), NULL)
#1 src/XF/App.php(1362): XF\Container->createObject('ForoAgency\\Shou...', Array)
#2 src/XF/Container.php(228): XF\App->XF\{closure}('ForoAgency\\Shou...', Array, Object(XF\Container))
#3 src/XF/App.php(2511): XF\Container->create('service', 'XF:Thread\\Repli...', Array)
#4 src/addons/XFA/XFMGMediaOfTheMonth/Service/Motm/ThreadNotifier.php(197): XF\App->service('XF:Thread\\Repli...', NULL)
#5 src/XF.php(397): XFA\XFMGMediaOfTheMonth\Service\Motm\ThreadNotifier->XFA\XFMGMediaOfTheMonth\Service\Motm\{closure}()
#6 src/addons/XFA/XFMGMediaOfTheMonth/Service/Motm/ThreadNotifier.php(209): XF::asVisitor(Object(ForumApps\API\XF\Entity\User), Object(Closure))
#7 src/addons/XFA/XFMGMediaOfTheMonth/Service/Media/Voter.php(78): XFA\XFMGMediaOfTheMonth\Service\Motm\ThreadNotifier->notify()
#8 src/addons/XFA/XFMGMediaOfTheMonth/XFMG/Pub/Controller/Media.php(49): XFA\XFMGMediaOfTheMonth\Service\Media\Voter->vote()
#9 src/XF/Mvc/Dispatcher.php(249): XFA\XFMGMediaOfTheMonth\XFMG\Pub\Controller\Media->actionVoteMotm(Object(XF\Mvc\ParameterBag))
#10 src/XF/Mvc/Dispatcher.php(88): XF\Mvc\Dispatcher->dispatchClass('XFMG:Media', 'VoteMotm', 'html', Object(XF\Mvc\ParameterBag), 'xfmg', Object(XFA\XFMGMediaOfTheMonth\XFMG\Pub\Controller\Media), NULL)
#11 src/XF/Mvc/Dispatcher.php(41): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#12 src/XF/App.php(1934): XF\Mvc\Dispatcher->run()
#13 src/XF.php(333): XF\App->run()
#14 index.php(13): XF::runApp('XF\\Pub\\App')
#15 {main}

Request state
array(4) {
["url"] => string(30) "/media/82-vette.1328/vote-motm"
["referrer"] => string(55) "https://canadiancorvetteforums.com/media/82-vette.1328/"
["_GET"] => array(1) {
["/media/82-vette_1328/vote-motm"] => string(0) ""
}
["_POST"] => array(1) {
["_xfToken"] => string(8) "****"
}
}

Mode 2, looks like vote isn't adding the reply now.
 
Top