X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FJsonLD.php;h=cd3a6ec2708899d49483a7bfb3c73a92c7d762cf;hb=9feab828c88dfdc0c66fef3269f6cdf0122d2840;hp=bed7a67d60a01eeccf58bc6a312f6f363541f4b6;hpb=0a9dba005c0c70302e37ab4ce7f9598984ec9953;p=friendica.git diff --git a/src/Util/JsonLD.php b/src/Util/JsonLD.php index bed7a67d60..cd3a6ec270 100644 --- a/src/Util/JsonLD.php +++ b/src/Util/JsonLD.php @@ -90,10 +90,16 @@ class JsonLD 'dfrn' => (object)['@id' => 'http://purl.org/macgirvin/dfrn/1.0/', '@type' => '@id'], 'diaspora' => (object)['@id' => 'https://diasporafoundation.org/ns/', '@type' => '@id'], 'ostatus' => (object)['@id' => 'http://ostatus.org#', '@type' => '@id'], - 'dc' => (object)['@id' => 'http://purl.org/dc/terms/', '@type' => '@id']]; + '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); @@ -103,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; } /**