[XFA] Media Of The Month - XF2

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

No permission to buy (€15.00)
Can't see the album as it's not accessible to unregistered users.
Do you have the follow set to yes :
Bypass album privacy (view all albums and contents)
 
Was not talking of the permission you highlighted but that one:
Bypass album privacy (view all albums and contents)

It's in Album moderator permissions.

I am suspecting somehow a privacy problem.
 
Was not talking of the permission you highlighted but that one:
Bypass album privacy (view all albums and contents)

It's in Album moderator permissions.

I am suspecting somehow a privacy problem.

That setting is also set to yes.
 
That was the one. Thanks.

No problem. Considering that, I should perhaps be adding in a further version some way to allow albums to be created in a dedicated category as that is now supported by xF2.
That would allow users such as you to avoid personal albums.

I hope I was able to make you change your mind on the review you posted ;)
 
You've extended the Thread Creator and Replier Services in your Core Add-on (which is used by this Add-on) in order to be able to automatically create threads/posts owned by a specific user:

This is not how things should be done in XF 2.

Example Code
PHP:
/** @var \XF\Service\Thread\Replier $replier */
$replier = \XF::app()->service('XF:Thread\Replier', $thread);
$replier->setAutomatedUser($messagePoster);
$replier->setMessage($this->message, false);

$replier->getPost()->message_state = 'visible';

if ($replier && $replier->validate())
{
    $existingLastPostDate = $replier->getThread()->last_post_date;

    $post = $replier->save();

    if (\XF::visitor()->user_id && $post->Thread->getVisitorReadDate() >= $existingLastPostDate)
    {
        $this->repository('XF:Thread')->markThreadReadByVisitor($post->Thread);
    }
}

This (and other similar occurances) should be refactored to smth. like
PHP:
$post = false;
$existingLastPostDate = $thread->last_post_date;

\XF::asVisitor($messagePoster, function () use ()
{
    /** @var \XF\Service\Thread\Replier $replier */
    $replier = \XF::app()->service('XF:Thread\Replier', $thread);
    $replier->setIsAutomated();
    $replier->setMessage($this->message, false);

    $replier->getPost()->message_state = 'visible';

    if ($replier && $replier->validate())
    {
        $post = $replier->save();
    }
}

if ($post !== false && \XF::visitor()->user_id && $thread->getVisitorReadDate() >= $existingLastPostDate)
{
    $this->repository('XF:Thread')->markThreadReadByVisitor($thread);
}

It would be nice if this could be changed in a future version :)
 
Last edited:
Ah I wasn't aware of the \XF::asVisitor thing.
Thanks for the info.

Extending the services is perhaps not the perfect way to do it but it's not forbidden so I would not be as strict as your statement :)
But I'll change that.
 
Another suggestion:
The setting for the thread creator should be a username, not a userid - this is exactly what Edit format User name input is made for:
It takes a username as input and stores the userid.
 
Another suggestion:
The setting for the thread creator should be a username, not a userid - this is exactly what Edit format User name input is made for:
It takes a username as input and stores the userid.

Indeed, didn't see that when doing xF2 version.
 
And again for 3rd month now the MOTM doesn't auto close and bombs out with an error.

Using latest core and motm. @XFA


Server error log
  • InvalidArgumentException: Attempted to convert NULL to string/binary [username]
  • src/XF/Mvc/Entity/Entity.php:691
  • Generated by: Unknown account
  • Oct 31, 2018 at 8:01 PM
Stack trace
#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/XF/Service/Thread/Replier.php(102): XF\Mvc\Entity\Entity->__set('username', NULL)
#3 src/XF/Service/Thread/Replier.php(40): XF\Service\Thread\Replier->setPostDefaults()
#4 src/XF/Container.php(274): XF\Service\Thread\Replier->__construct(Object(XF\Pub\App), Object(ForumApps\API\XF\Entity\Thread))
#5 src/XF/App.php(1359): XF\Container->createObject('XFA\\Core\\XF\\Ser...', Array)
#6 src/XF/Container.php(228): XF\App->XF\{closure}('XFA\\Core\\XF\\Ser...', Array, Object(XF\Container))
#7 src/XF/App.php(2508): XF\Container->create('service', 'XF:Thread\\Repli...', Array)
#8 src/addons/XFA/XFMGMediaOfTheMonth/Service/Motm/ThreadNotifier.php(179): XF\App->service('XF:Thread\\Repli...', Object(ForumApps\API\XF\Entity\Thread))
#9 src/addons/XFA/XFMGMediaOfTheMonth/Service/Motm/WinnerAwarder.php(242): XFA\XFMGMediaOfTheMonth\Service\Motm\ThreadNotifier->notify()
#10 src/addons/XFA/XFMGMediaOfTheMonth/Cron/XFMGMediaOfTheMonth.php(213): XFA\XFMGMediaOfTheMonth\Service\Motm\WinnerAwarder->findAndAwardWinner(2)
#11 src/addons/XFA/XFMGMediaOfTheMonth/Cron/XFMGMediaOfTheMonth.php(23): XFA\XFMGMediaOfTheMonth\Cron\XFMGMediaOfTheMonth::cronMode2()
#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(7.9957370758057)
#15 src/XF/Job/Manager.php(187): XF\Job\Manager->runJobInternal(Array, 7.9957370758057)
#16 src/XF/Job/Manager.php(76): XF\Job\Manager->runJobEntry(Array, 7.9957370758057)
#17 job.php(14): XF\Job\Manager->runQueue(false, 8)
#18 {main}

-------------

Previous InvalidArgumentException: Attempted to convert NULL to string/binary - src/XF/Mvc/Entity/ValueFormatter.php:130
#0 src/XF/Mvc/Entity/Entity.php(687): XF\Mvc\Entity\ValueFormatter->castValueToType(NULL, 5, Array)
#1 src/XF/Mvc/Entity/Entity.php(575): XF\Mvc\Entity\Entity->_castValueToType(NULL, 'username', 5, Array)
#2 src/XF/Mvc/Entity/Entity.php(505): XF\Mvc\Entity\Entity->set('username', NULL)
#3 src/XF/Service/Thread/Replier.php(102): XF\Mvc\Entity\Entity->__set('username', NULL)
#4 src/XF/Service/Thread/Replier.php(40): XF\Service\Thread\Replier->setPostDefaults()
#5 src/XF/Container.php(274): XF\Service\Thread\Replier->__construct(Object(XF\Pub\App), Object(ForumApps\API\XF\Entity\Thread))
#6 src/XF/App.php(1359): XF\Container->createObject('XFA\\Core\\XF\\Ser...', Array)
#7 src/XF/Container.php(228): XF\App->XF\{closure}('XFA\\Core\\XF\\Ser...', Array, Object(XF\Container))
#8 src/XF/App.php(2508): XF\Container->create('service', 'XF:Thread\\Repli...', Array)
#9 src/addons/XFA/XFMGMediaOfTheMonth/Service/Motm/ThreadNotifier.php(179): XF\App->service('XF:Thread\\Repli...', Object(ForumApps\API\XF\Entity\Thread))
#10 src/addons/XFA/XFMGMediaOfTheMonth/Service/Motm/WinnerAwarder.php(242): XFA\XFMGMediaOfTheMonth\Service\Motm\ThreadNotifier->notify()
#11 src/addons/XFA/XFMGMediaOfTheMonth/Cron/XFMGMediaOfTheMonth.php(213): XFA\XFMGMediaOfTheMonth\Service\Motm\WinnerAwarder->findAndAwardWinner(2)
#12 src/addons/XFA/XFMGMediaOfTheMonth/Cron/XFMGMediaOfTheMonth.php(23): XFA\XFMGMediaOfTheMonth\Cron\XFMGMediaOfTheMonth::cronMode2()
#13 [internal function]: XFA\XFMGMediaOfTheMonth\Cron\XFMGMediaOfTheMonth::cron(Object(XF\Entity\CronEntry))
#14 src/XF/Job/Cron.php(35): call_user_func(Array, Object(XF\Entity\CronEntry))
#15 src/XF/Job/Manager.php(241): XF\Job\Cron->run(7.9957370758057)
#16 src/XF/Job/Manager.php(187): XF\Job\Manager->runJobInternal(Array, 7.9957370758057)
#17 src/XF/Job/Manager.php(76): XF\Job\Manager->runJobEntry(Array, 7.9957370758057)
#18 job.php(14): XF\Job\Manager->runQueue(false, 8)
#19 {main}
 
The award thread is supposed to be using the user you set in admincp as the poster.
You did set that to an existing user ?
 
The award thread is supposed to be using the user you set in admincp as the poster.
You did set that to an existing user ?

Of course, it's been creating media submission posts with my admin user. Award post though was not created. Media is awarded. Award post generates that error. It's exactly the same problem as before.
 
Might be because of the way I did things as pointed by Kirby above, I'll do that change and see if that fixes.
Odd is that you are the only one to report that.
 
Top Bottom