X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FJsonLD.php;h=cd3a6ec2708899d49483a7bfb3c73a92c7d762cf;hb=9feab828c88dfdc0c66fef3269f6cdf0122d2840;hp=78d81816e25b1747c0f749e9488470bdcdfb6727;hpb=1a3c88b042c37ce9e143a347fac8516fdf11a448;p=friendica.git diff --git a/src/Util/JsonLD.php b/src/Util/JsonLD.php index 78d81816e2..cd3a6ec270 100644 --- a/src/Util/JsonLD.php +++ b/src/Util/JsonLD.php @@ -93,8 +93,13 @@ class JsonLD 'dc' => (object)['@id' => 'http://purl.org/dc/terms/', '@type' => '@id'], 'toot' => (object)['@id' => 'http://joinmastodon.org/ns#', '@type' => '@id']]; - $jsonobj = json_decode(json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); + // Trying to avoid memory problems with large content fields + if (!empty($json['object']['source']['content'])) { + $content = $json['object']['source']['content']; + $json['object']['source']['content'] = ''; + } + $jsonobj = json_decode(json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); try { $compacted = jsonld_compact($jsonobj, $context); @@ -104,7 +109,13 @@ class JsonLD Logger::log('compacting error:' . print_r($e, true), Logger::DEBUG); } - return json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true); + $json = json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true); + + if (isset($json['as:object']['as:source']['as:content']) && !empty($content)) { + $json['as:object']['as:source']['as:content'] = $content; + } + + return $json; } /**