Merge pull request #6252 from annando/memory

Possibly fix a memory issue with large posts
2022.09-rc
Hypolite Petovan 2018-12-11 15:13:40 -05:00 zatwierdzone przez GitHub
commit 5147d05c53
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 14 dodań i 2 usunięć

Wyświetl plik

@ -291,6 +291,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
$parent = Item::selectFirst(['uid'], ['uri' => $item_parent_uri, 'wall' => true]); $parent = Item::selectFirst(['uid'], ['uri' => $item_parent_uri, 'wall' => true]);
if (DBA::isResult($parent)) { if (DBA::isResult($parent)) {
$a->profile['uid'] = $parent['uid'];
$a->profile['profile_uid'] = $parent['uid']; $a->profile['profile_uid'] = $parent['uid'];
$is_remote_contact = Contact::isFollower(remote_user(), $a->profile['profile_uid']); $is_remote_contact = Contact::isFollower(remote_user(), $a->profile['profile_uid']);
} }

Wyświetl plik

@ -93,8 +93,13 @@ class JsonLD
'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']]; '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 { try {
$compacted = jsonld_compact($jsonobj, $context); $compacted = jsonld_compact($jsonobj, $context);
@ -104,7 +109,13 @@ class JsonLD
Logger::log('compacting error:' . print_r($e, true), Logger::DEBUG); 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;
} }
/** /**