DragonByte Tech
Well-known member
- Affected version
- 2.3.0 Beta 6
Assume you have a getter like this:
In your entity's
Sending the webhook will cause this error:
LogicException: Instances of XF\Db\AbstractAdapter cannot be serialized or unserialized in src/XF/Db/AbstractAdapter.php at line 686
Dumping
I'm not sure 100% what's at fault here, but from looking at
PHP:
public function getTagline(): \XF\Phrase
{
return \XF::phrase($this->getTaglinePhraseName());
}
In your entity's
setupApiResultData
you include it like so: $result->includeGetter('tagline');
Sending the webhook will cause this error:
LogicException: Instances of XF\Db\AbstractAdapter cannot be serialized or unserialized in src/XF/Db/AbstractAdapter.php at line 686
- XF\Db\AbstractAdapter->__sleep()
- serialize() in src/XF/Job/Manager.php at line 581
- XF\Job\Manager->_enqueue() in src/XF/Job/Manager.php at line 493
- XF\Job\Manager->enqueue() in src/XF/Repository/Webhook.php at line 127
- XF\Repository\Webhook->queueWebhook() in src/XF/Behavior/Webhook.php at line 33
- XF\Behavior\Webhook->postSave() in src/XF/Mvc/Entity/Entity.php at line 1317
- XF\Mvc\Entity\Entity->save() in src/addons/DBTech/eCommerce/Service/Product/Edit.php at line 564
- DBTech\eCommerce\Service\Product\Edit->_save() in src/XF/Service/ValidateAndSavableTrait.php at line 42
- DBTech\eCommerce\Service\Product\Edit->save() in src/addons/DBTech/eCommerce/Admin/Controller/Product.php at line 599
- DBTech\eCommerce\Admin\Controller\Product->actionSave() in src/XF/Mvc/Dispatcher.php at line 352
- XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 258
- XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
- XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
- XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2604
- XF\App->run() in src/XF.php at line 533
- XF::runApp() in admin.php at line 13
Dumping
$payload
shows the phrase is not being rendered:I'm not sure 100% what's at fault here, but from looking at
XF/Api/Result/EntityResult::castToFinalValue
it would seem like the simplest solution would be this:
Diff:
--- src/XF/Api/Result/EntityResult.php 2024-05-09 15.26.25.000000000
+++ src/XF/Api/Result/EntityResult.php 2024-05-09 15.26.09.000000000
@@ -222,13 +222,13 @@
else
{
$value = $value->toWebhookResults($verbosity, $options);
}
}
- if ($value instanceof ResultInterface)
+ if ($value instanceof ResultInterface || $value instanceof \XF\Phrase)
{
$value = $value->render();
}
return $value;
}