diff --git a/lib/Db/CacheActorsRequest.php b/lib/Db/CacheActorsRequest.php index 7a3f0ff2..8698b29f 100644 --- a/lib/Db/CacheActorsRequest.php +++ b/lib/Db/CacheActorsRequest.php @@ -66,6 +66,11 @@ class CacheActorsRequest extends CacheActorsRequestBuilder { * @return int */ public function save(Person $actor): int { + $source = $actor->getSource(); + if (sizeof($source) >= CoreRequestBuilder::SOURCE_LENGTH) { + $source = 'too_big'; + } + $qb = $this->getCacheActorsInsertSql(); $qb->setValue('id', $qb->createNamedParameter($actor->getId())) ->setValue('account', $qb->createNamedParameter($actor->getAccount())) @@ -84,7 +89,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder { ->setValue('name', $qb->createNamedParameter($actor->getName())) ->setValue('summary', $qb->createNamedParameter($actor->getSummary())) ->setValue('public_key', $qb->createNamedParameter($actor->getPublicKey())) - ->setValue('source', $qb->createNamedParameter($actor->getSource())) + ->setValue('source', $qb->createNamedParameter($source)) ->setValue('details', $qb->createNamedParameter(json_encode($actor->getDetails()))) ->setValue( 'creation', diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index 7176ed8c..8f594ddd 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -64,6 +64,9 @@ class CoreRequestBuilder { const TABLE_CACHE_DOCUMENTS = 'social_cache_documents'; + const SOURCE_LENGTH = 10000; + + /** @var IDBConnection */ protected $dbConnection; diff --git a/lib/Db/NotesRequest.php b/lib/Db/NotesRequest.php index 9e687e25..10b155e7 100644 --- a/lib/Db/NotesRequest.php +++ b/lib/Db/NotesRequest.php @@ -68,6 +68,11 @@ class NotesRequest extends NotesRequestBuilder { $dTime = new DateTime(); $dTime->setTimestamp($note->getPublishedTime()); + $source = $note->getSource(); + if (sizeof($source) >= CoreRequestBuilder::SOURCE_LENGTH) { + $source = 'too_big'; + } + $qb = $this->getNotesInsertSql(); $qb->setValue('id', $qb->createNamedParameter($note->getId())) ->setValue('type', $qb->createNamedParameter($note->getType())) @@ -95,7 +100,7 @@ class NotesRequest extends NotesRequestBuilder { ) ->setValue('attributed_to', $qb->createNamedParameter($note->getAttributedTo())) ->setValue('in_reply_to', $qb->createNamedParameter($note->getInReplyTo())) - ->setValue('source', $qb->createNamedParameter($note->getSource())) + ->setValue('source', $qb->createNamedParameter($source)) ->setValue( 'instances', $qb->createNamedParameter( json_encode($note->getInstancePaths(), JSON_UNESCAPED_SLASHES)