X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FJsonLD.php;h=beb01f0cc1106f54683ed1454e15e9a8f1d8b111;hb=0a45bdd3b71ec0f8744abb3830858a91a4bca146;hp=947274134ccf91c8c88a5edc5af4fb76ca2835c2;hpb=8c602071c2070b78c4780c2d0d72b4599b6483cb;p=friendica.git diff --git a/src/Util/JsonLD.php b/src/Util/JsonLD.php index 947274134c..beb01f0cc1 100644 --- a/src/Util/JsonLD.php +++ b/src/Util/JsonLD.php @@ -1,6 +1,6 @@ $url]); @@ -140,7 +146,7 @@ class JsonLD * @return array Compacted JSON array * @throws Exception */ - public static function compact($json, bool $logfailed = true) + public static function compact($json, bool $logfailed = true): array { jsonld_set_document_loader('Friendica\Util\JsonLD::documentLoader'); @@ -157,6 +163,8 @@ class JsonLD 'sc' => (object)['@id' => 'http://schema.org#', '@type' => '@id'], 'pt' => (object)['@id' => 'https://joinpeertube.org/ns#', '@type' => '@id'], 'mobilizon' => (object)['@id' => 'https://joinmobilizon.org/ns#', '@type' => '@id'], + 'fedibird' => (object)['@id' => 'http://fedibird.com/ns#', '@type' => '@id'], + 'misskey' => (object)['@id' => 'https://misskey-hub.net/ns#', '@type' => '@id'], ]; $orig_json = $json; @@ -201,6 +209,11 @@ class JsonLD $json = json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true); + if ($json === false) { + Logger::notice('JSON encode->decode failed', ['orig_json' => $orig_json, 'compacted' => $compacted]); + $json = []; + } + return $json; }