Skip to content

Commit

Permalink
- json_encode will error on resource values; doctrine treats blob col…
Browse files Browse the repository at this point in the history
…umns as resource streams; when getting the old/new values from the diff, check for resource variable, rewind if necessary.
  • Loading branch information
chancegarcia committed Apr 2, 2020
1 parent 9012a27 commit e057f22
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/DataDog/AuditBundle/EventSubscriber/AuditSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,16 @@ protected function label(EntityManager $em, $entity)

protected function value(EntityManager $em, Type $type, $value)
{
// json_encode will error when trying to encode a resource
if (is_resource($value)) {
// https://stackoverflow.com/questions/26303513/getting-blob-type-doctrine-entity-property-returns-data-only-once/26306571
if (0 !== ftell($value)) {
rewind($value);
}

$value = stream_get_contents($value);
}

$platform = $em->getConnection()->getDatabasePlatform();
switch ($type->getName()) {
case Type::BOOLEAN:
Expand Down

0 comments on commit e057f22

Please sign in to comment.