Webhooks on for all error creating new thread with inlined image attachment

Mike Fara

Active member
Affected version
2.3.0
My ability to test this on a test bed is limited at this time, but enabled web hooks last night... look at this:

1721326820900.webp

Code:
Server error log
[LIST]
[*]TypeError: XF\Mvc\Entity\AbstractCollection::toWebhookResults(): Argument #1 ($options) must be of type array, int given, called in /web/public_html/src/XF/Api/Result/EntityResult.php on line 226
[*]src/XF/Mvc/Entity/AbstractCollection.php:72
[*]Generated by: Mike
[*]Jul 18, 2024 at 2:13 PM
[/LIST]
[HEADING=2]Stack trace[/HEADING]
#0 src/XF/Api/Result/EntityResult.php(226): XF\Mvc\Entity\AbstractCollection->toWebhookResults(1, Array)
#1 src/XF/Api/Result/EntityResult.php(174): XF\Api\Result\EntityResult->castToFinalValue(Object(XF\Mvc\Entity\ArrayCollection), 1, Array)
#2 src/XF/Repository/WebhookRepository.php(113): XF\Api\Result\EntityResult->render()
#3 src/XF/Behavior/Webhook.php(34): XF\Repository\WebhookRepository->queueWebhook('post', 854629, 'update', Object(XFMG\XF\Entity\Post))
#4 src/XF/Mvc/Entity/Entity.php(1327): XF\Behavior\Webhook->postSave()
#5 src/XF/Mvc/Entity/Entity.php(1318): XF\Mvc\Entity\Entity->save(true, false)
#6 src/XF/Tag/AbstractHandler.php(44): XF\Mvc\Entity\Entity->save()
#7 src/XF/Repository/TagRepository.php(406): XF\Tag\AbstractHandler->updateContentTagCache(Object(XFMG\XF\Entity\Thread), Array)
#8 src/XF/Service/Tag/ChangerService.php(326): XF\Repository\TagRepository->modifyContentTags('thread', 339603, Array, Array)
#9 src/XF/Service/Thread/CreatorService.php(542): XF\Service\Tag\ChangerService->save(true)
#10 src/addons/DigitalPoint/Analytics/XF/Service/Thread/Creator.php(9): XF\Service\Thread\CreatorService->_save()
#11 src/addons/Snog/OSBrowser/XF/Service/Thread/Creator.php(9): DigitalPoint\Analytics\XF\Service\Thread\Creator->_save()
#12 src/XF/Service/ValidateAndSavableTrait.php(42): Snog\OSBrowser\XF\Service\Thread\Creator->_save()
#13 src/XF/Pub/Controller/ForumController.php(961): XF\Service\Thread\CreatorService->save()
#14 src/XF/Mvc/Dispatcher.php(362): XF\Pub\Controller\ForumController->actionPostThread(Object(XF\Mvc\ParameterBag))
#15 src/XF/Mvc/Dispatcher.php(264): XF\Mvc\Dispatcher->dispatchClass('XF:Forum', 'PostThread', Object(XF\Mvc\RouteMatch), Object(SV\StandardLib\XF\Pub\Controller\Forum), NULL)
#16 src/XF/Mvc/Dispatcher.php(121): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(SV\StandardLib\XF\Pub\Controller\Forum), NULL)
#17 src/XF/Mvc/Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#18 src/XF/App.php(2777): XF\Mvc\Dispatcher->run()
#19 src/XF.php(798): XF\App->run()
#20 index.php(23): XF::runApp('XF\\Pub\\App')
#21 {main}
[HEADING=2]Request state[/HEADING]
array(4) {
  ["url"] => string(34) "/forums/staff-forum.23/post-thread"
  ["referrer"] => string(58) "https://windowsforum.com/forums/staff-forum.23/post-thread"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(16) {
    ["_xfToken"] => string(8) "********"
    ["prefix_id"] => string(1) "0"
    ["title"] => string(51) "Test post with image discord integration turned off"
    ["discussion_type"] => string(10) "discussion"
    ["message_html"] => string(147) "<p><img alt="" data-attachment="full:44365" src="/attachments/test-jpg.44365/?hash=52017b914ee131197810f44cc1773110" class="fr-fic fr-dii"><br></p>"
    ["attachment_hash"] => string(32) "52017b914ee131197810f44cc1773110"
    ["attachment_hash_combined"] => string(82) "{"type":"post","context":{"node_id":23},"hash":"52017b914ee131197810f44cc1773110"}"
    ["chatgpt_autoresponder"] => string(3) "yes"
    ["tags"] => string(0) ""
    ["watch_thread"] => string(1) "1"
    ["_xfSet"] => array(4) {
      ["watch_thread"] => string(1) "1"
      ["discussion_open"] => string(1) "1"
      ["sticky"] => string(1) "1"
      ["index_state"] => string(1) "1"
    }
    ["discussion_open"] => string(1) "1"
    ["index_state"] => string(7) "default"
    ["_xfRequestUri"] => string(34) "/forums/staff-forum.23/post-thread"
    ["_xfWithData"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}
What did I break?
 
The issue is that XF\Api\Result\EntityResult::castToFinalValue() is calling XF\Mvc\Entity\AbstractCollection::toWebhookResults() with a parameter it doesn't support ($verbosity isn't a parameter that it can take).

1723738151483.webp
 
Temporary fix is on line 226 swap the arguments - EntityResult.php:

Code:
$value = $value->toWebhookResults($verbosity, $options);

Corrected line:

Code:
$value = $value->toWebhookResults($options, $verbosity);
 
Back
Top Bottom