Steffen
Well-known member
The class
Reasoning: I'm using the XenForo API to programmatically create and update threads (and their first post). When I initialize XenForo using
Workaround: I could initialize my CLI app using
Code to reproduce the issue (assumes that a post with ID 1 exists):
XF/Service/Thread/Editor
has a method setPerformValidations
. I think XF\Service\Post\Editor
should have such a method, too. It should be used to skip the PostPreparer
validation called by XF\Service\Post\Editor::setMessage
, just like the ThreadEditor does.Reasoning: I'm using the XenForo API to programmatically create and update threads (and their first post). When I initialize XenForo using
\XF::setupApp('XF\App');
and call XF\Service\Post\Editor::setMessage
I get an error: "[LogicException] The router key must be overridden." I think that's because the PostEditor service currently does not allow skipping the PostPreparer validation.Workaround: I could initialize my CLI app using
\XF::setupApp('XF\Pub\App');
. But I guess the Pub app is only meant to be used when handling a web request, or is this a misunderstanding and I should even use the Pub app in CLI mode?Code to reproduce the issue (assumes that a post with ID 1 exists):
PHP:
<?php
$dir = __DIR__;
require $dir . '/src/XF.php';
\XF::start($dir);
$app = \XF::setupApp('XF\App');
$app->setup();
$finder = $app->em()->getFinder('XF:Post');
$finder->where('post_id', 1);
$post = $finder->fetchOne();
$postEditor = $app->service('XF:Post\Editor', $post);
$postEditor->setMessage('A message ...');
$postEditor->save();
Upvote
0