1
0

PHP8 compat fixes for entry form display

This commit is contained in:
onli
2021-05-02 11:45:14 +02:00
parent b2707b81ae
commit 7900062aa3
2 changed files with 14 additions and 7 deletions

View File

@ -424,7 +424,9 @@ function serendipity_fetchUsers($user = '', $group = null, $is_count = false) {
$group_sql = (int)$group; $group_sql = (int)$group;
} }
if ($group_sql) $where .= ' AND ' . "g.id IN ($group_sql)"; if ($group_sql ?? false) {
$where .= ' AND ' . "g.id IN ($group_sql)";
}
$querystring = "SELECT $query_distinct $querystring = "SELECT $query_distinct
a.authorid, a.authorid,

View File

@ -33,7 +33,7 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
serendipity_plugin_api::hook_event('backend_entryform', $entry); serendipity_plugin_api::hook_event('backend_entryform', $entry);
if ( (isset($entry['isdraft']) && serendipity_db_bool($entry['isdraft'])) || if ( (isset($entry['isdraft']) && serendipity_db_bool($entry['isdraft'])) ||
(!isset($entry['isdraft']) && $serendipity['publishDefault'] == 'draft') ) { (!isset($entry['isdraft']) && ($serendipity['publishDefault'] ?? null) == 'draft') ) {
$draftD = ' selected="selected"'; $draftD = ' selected="selected"';
$template_vars['draft_mode'] = 'draft'; $template_vars['draft_mode'] = 'draft';
} else { } else {
@ -44,7 +44,7 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
if (isset($entry['moderate_comments']) && (serendipity_db_bool($entry['moderate_comments']))) { if (isset($entry['moderate_comments']) && (serendipity_db_bool($entry['moderate_comments']))) {
$template_vars['moderate_comments'] = true; $template_vars['moderate_comments'] = true;
$moderate_comments = ' checked="checked"'; $moderate_comments = ' checked="checked"';
} elseif (!isset($entry['moderate_comments']) && ($serendipity['moderateCommentsDefault'] == 'true' || $serendipity['moderateCommentsDefault'] === true)) { } elseif (!isset($entry['moderate_comments']) && (isset($serendipity['moderateCommentsDefault']) && ($serendipity['moderateCommentsDefault'] == 'true' || $serendipity['moderateCommentsDefault'] === true))) {
// This is the default on creation of a new entry and depends on the "moderateCommentsDefault" variable of the configuration. // This is the default on creation of a new entry and depends on the "moderateCommentsDefault" variable of the configuration.
$moderate_comments = ' checked="checked"'; $moderate_comments = ' checked="checked"';
$template_vars['moderate_comments'] = true; $template_vars['moderate_comments'] = true;
@ -66,7 +66,7 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
} }
// Fix category list. If the entryForm is displayed after a POST request, the additional category information is lost. // Fix category list. If the entryForm is displayed after a POST request, the additional category information is lost.
if (is_array($entry['categories']) && !is_array($entry['categories'][0])) { if (is_array($entry['categories'] ?? null) && !is_array($entry['categories'][0])) {
$categories = (array)$entry['categories']; $categories = (array)$entry['categories'];
$entry['categories'] = array(); $entry['categories'] = array();
foreach ($categories as $catid) { foreach ($categories as $catid) {
@ -75,7 +75,7 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
} }
$selected = array(); $selected = array();
if (is_array($entry['categories'])) { if (is_array($entry['categories'] ?? null)) {
if (count($entry['categories']) > 1) { if (count($entry['categories']) > 1) {
$categoryselector_expanded = true; $categoryselector_expanded = true;
} }
@ -83,7 +83,7 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
foreach ($entry['categories'] as $cat) { foreach ($entry['categories'] as $cat) {
$selected[] = $cat['categoryid']; $selected[] = $cat['categoryid'];
} }
} elseif ($serendipity['categoryDefault'] > 0) { } elseif (($serendipity['categoryDefault'] ?? 0) > 0) {
$selected[] = $serendipity['categoryDefault']; $selected[] = $serendipity['categoryDefault'];
} }
@ -104,12 +104,17 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
$template_vars['category_options'][] = $cat; $template_vars['category_options'][] = $cat;
} }
} else {
$template_vars['category_options'] = [];
} }
if (!empty($serendipity['GET']['title'])) { if (!empty($serendipity['GET']['title'])) {
$entry['title'] = utf8_decode(urldecode($serendipity['GET']['title'])); $entry['title'] = utf8_decode(urldecode($serendipity['GET']['title']));
} else {
$entry['title'] = null;
} }
if (!empty($serendipity['GET']['body'])) { if (!empty($serendipity['GET']['body'])) {
$entry['body'] = utf8_decode(urldecode($serendipity['GET']['body'])); $entry['body'] = utf8_decode(urldecode($serendipity['GET']['body']));
} }
@ -138,7 +143,7 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
$template_vars['entry'] =& $entry; $template_vars['entry'] =& $entry;
$template_vars['targetURL'] = $targetURL; $template_vars['targetURL'] = $targetURL;
$template_vars['cat_count'] = is_array($cats) ? (count($cats)+1) : 1; $template_vars['cat_count'] = is_array($cats) ? (count($cats)+1) : 1;
$template_vars['wysiwyg'] = $serendipity['wysiwyg']; $template_vars['wysiwyg'] = $serendipity['wysiwyg'] ?? null;
$template_vars['serendipityRightPublish'] = $_SESSION['serendipityRightPublish']; $template_vars['serendipityRightPublish'] = $_SESSION['serendipityRightPublish'];
$template_vars['wysiwyg_blocks'] = array( $template_vars['wysiwyg_blocks'] = array(
'body' => 'serendipity[body]', 'body' => 'serendipity[body]',