codeberg issue #9, white screen of death when editing post containing share

This commit is contained in:
Mike Macgirvin 2022-09-11 11:10:20 +10:00
parent 5de08abfdc
commit 5f4ec5f5d7
2 changed files with 16 additions and 2 deletions

View file

@ -107,10 +107,25 @@ class Editpost extends Controller
$j = json_decode($item['attach'], true);
if ($j) {
foreach ($j as $jj) {
if (!str_starts_with($jj['type'],'application/ld+json')) {
$item['body'] .= "\n" . '[attachment]' . basename($jj['href']) . ',' . $jj['revision'] . '[/attachment]' . "\n";
}
}
}
}
$matches = [];
if (preg_match_all("/\[share(.*?)message_id='(.*?)'(.*?)\[\/share]/ism",$item['body'], $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$r = q("select * from item where mid = '%s' and uid = %d",
dbesc($match[2]),
intval($item['uid'])
);
if ($r) {
$item['body'] = str_replace($match[0], '[share=' . $r[0]['id'] . '][/share]', $item['body']);
}
}
}
if (intval($item['item_unpublished'])) {
// clear the old creation date if editing a saved draft. These will always show as just created.

View file

@ -2049,7 +2049,6 @@ function item_store_update($arr, $allow_exec = false, $deliver = true, $linkid =
$arr['attach'] = item_json_encapsulate($arr,'attach');
}
unset($arr['id']);
unset($arr['uid']);
unset($arr['aid']);