Php8 fixes for #766 (#769)

* init empty vars to avoid PHP8 warnings

* removed debug output for serendipity_session_destroy()

* init smarty fixed for PHP8

* removed optional parameters for PHP 8

* 2k11 template fixes, maybe updating smarty will solve everything

* init or test undefined variables for PHP 8

* remove only existing files

* make sure string is not empty before comparing the first letter

* check if SMARTY_DIR was already defined

* use mb_language('uni') for unicode

* fixed image filter bug

* Smarty debug fixed in external lib

* fixed archive bug

* fixed entries bug

* updated plugin versions

Co-authored-by: surrim <surrim@happyhydro.org>
This commit is contained in:
surrim 2021-07-18 22:14:23 +02:00 committed by GitHub
parent 1b162d33a8
commit 9a60f9a494
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 217 additions and 127 deletions

View File

@ -69,8 +69,10 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
public function end_template(Smarty_Internal_Template $template)
{
$key = $this->get_key($template);
$this->template_data[ $this->index ][ $key ][ 'total_time' ] +=
microtime(true) - $this->template_data[ $this->index ][ $key ][ 'start_template_time' ];
if (isset($this->template_data[ $this->index ][ $key ][ 'start_template_time' ])) {
$this->template_data[ $this->index ][ $key ][ 'total_time' ] +=
microtime(true) - $this->template_data[ $this->index ][ $key ][ 'start_template_time' ];
}
//$this->template_data[$this->index][$key]['properties'] = $template->properties;
}
@ -142,8 +144,10 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
public function end_render(Smarty_Internal_Template $template)
{
$key = $this->get_key($template);
$this->template_data[ $this->index ][ $key ][ 'render_time' ] +=
microtime(true) - $this->template_data[ $this->index ][ $key ][ 'start_time' ];
if (isset($this->template_data[ $this->index ][ $key ][ 'start_time' ])) {
$this->template_data[ $this->index ][ $key ][ 'render_time' ] +=
microtime(true) - $this->template_data[ $this->index ][ $key ][ 'start_time' ];
}
}
/**

View File

@ -375,7 +375,7 @@ $data['formtoken'] = serendipity_setFormToken();
$data['get']['filter'] = $serendipity['GET']['filter']; // don't trust {$smarty.get.vars} if not proofed, as we often change GET vars via serendipty['GET'] by runtime
$data['commentReplied'] = false;
if (!is_object($serendipity['smarty'])) {
if (!is_object($serendipity['smarty'] ?? null)) {
serendipity_smarty_init();
}

View File

@ -65,7 +65,7 @@ if ($_POST['installAction'] == 'check' && serendipity_checkFormToken()) {
$data['config'] = serendipity_printConfigTemplate(serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE), $serendipity, false, true);
if (!is_object($serendipity['smarty'])) {
if (!is_object($serendipity['smarty'] ?? null)) {
serendipity_smarty_init();
}

View File

@ -4,7 +4,7 @@ if (IN_serendipity !== true) {
die ('Don\'t hack!');
}
if (!is_object($serendipity['smarty'])) {
if (!is_object($serendipity['smarty'] ?? null)) {
serendipity_smarty_init();
}

View File

@ -32,7 +32,7 @@ if (isset($_POST['SAVE_NEW']) && serendipity_checkFormToken()) {
/* Edit a group */
if (isset($_POST['SAVE_EDIT']) && serendipity_checkFormToken()) {
$perms = serendipity_getAllPermissionNames();
serendipity_updateGroupConfig($serendipity['POST']['group'], $perms, $serendipity['POST'], false, $serendipity['POST']['forbidden_plugins'], $serendipity['POST']['forbidden_hooks']);
serendipity_updateGroupConfig($serendipity['POST']['group'], $perms, $serendipity['POST'], false, ($serendipity['POST']['forbidden_plugins'] ?? null), ($serendipity['POST']['forbidden_hooks'] ?? null));
$data['save_edit'] = true;
$data['name'] = $serendipity['POST']['name'];
}

View File

@ -10,7 +10,7 @@ if (!serendipity_checkPermission('adminImages')) {
$data = array();
if (!is_object($serendipity['smarty'])) {
if (!is_object($serendipity['smarty'] ?? null)) {
serendipity_smarty_init();
}
@ -518,8 +518,8 @@ switch ($serendipity['GET']['adminAction']) {
$use_dir = $newDir;
}
serendipity_ACLGrant(0, 'directory', 'read', $serendipity['POST']['read_authors'], $use_dir);
serendipity_ACLGrant(0, 'directory', 'write', $serendipity['POST']['write_authors'], $use_dir);
serendipity_ACLGrant(0, 'directory', 'read', $serendipity['POST']['read_authors'] ?? null, $use_dir);
serendipity_ACLGrant(0, 'directory', 'write', $serendipity['POST']['write_authors'] ?? null, $use_dir);
$data['print_SETTINGS_SAVED_AT'] = sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S'));
}

View File

@ -252,7 +252,7 @@ if (isset($serendipity['GET']['importFrom']) && serendipity_checkFormToken()) {
$data['list'] = $list;
}
if (!is_object($serendipity['smarty'])) {
if (!is_object($serendipity['smarty'] ?? null)) {
serendipity_smarty_init();
}

View File

@ -258,7 +258,7 @@ class Serendipity_Import_b2evolution extends Serendipity_Import {
return true;
}
function importCategories($parentid = 0, $new_parentid = 0, $b2db) {
function importCategories($parentid = 0, $new_parentid = 0, $b2db = null) {
if (is_null($parentid)) {
$where = 'WHERE ISNULL(cat_parent_ID)';
} else {

View File

@ -265,7 +265,7 @@ class Serendipity_Import_lifetype extends Serendipity_Import {
return true;
}
function importCategories($parentid = 0, $new_parentid = 0, $ltdb) {
function importCategories($parentid = 0, $new_parentid = 0, $ltdb = null) {
if (is_null($parentid)) {
$where = 'WHERE parent_id = 0';
} else {

View File

@ -240,7 +240,7 @@ class Serendipity_Import_sunlog extends Serendipity_Import {
return true;
}
function importCategories($parentid = 0, $new_parentid = 0, $sunlogdb) {
function importCategories($parentid = 0, $new_parentid = 0, $sunlogdb = null) {
$where = "WHERE parent = '" . mysqli_escape_string($parentid) . "'";
$res = $this->nativeQuery("SELECT * FROM {$this->data['prefix']}categories

View File

@ -218,7 +218,7 @@ class Serendipity_Import_textpattern extends Serendipity_Import {
return true;
}
function importCategories($parentname = 'root', $parentid = 0, $txpdb) {
function importCategories($parentname = 'root', $parentid = 0, $txpdb = null) {
$res = $this->nativeQuery("SELECT * FROM {$this->data['prefix']}txp_category
WHERE parent = '" . mysqli_escape_string($parentname) . "' AND type = 'article'", $txpdb);
if (!$res) {

View File

@ -121,7 +121,7 @@ $data['config'] = serendipity_printConfigTemplate($template, $from, true, false)
$add = array('internal' => true);
serendipity_plugin_api::hook_event('backend_sidebar_entries_event_display_profiles', $from, $add);
if (!is_object($serendipity['smarty'])) {
if (!is_object($serendipity['smarty'] ?? null)) {
serendipity_smarty_init();
}

View File

@ -36,7 +36,7 @@ class template_option
WHERE okey = 't_" . serendipity_db_escape_string($serendipity['template']) . "'
AND name = '" . serendipity_db_escape_string($item) . "'");
if ($this->config[$item]['scope'] == 'global') {
if (($this->config[$item]['scope'] ?? '') == 'global') {
serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}options
WHERE okey = 't_global'
AND name = '" . serendipity_db_escape_string($item) . "'");

View File

@ -484,7 +484,7 @@ if (($showAbort && $serendipity['GET']['action'] == 'ignore') || $serendipity['G
$data['get']['action'] = $serendipity['GET']['action']; // don't trust {$smarty.get.vars} if not proofed, as we often change GET vars via serendipty['GET'] by runtime
$data['templatePath'] = $serendipity['templatePath'];
if (!is_object($serendipity['smarty'])) {
if (!is_object($serendipity['smarty'] ?? null)) {
serendipity_smarty_init();
}

View File

@ -359,8 +359,7 @@ function serendipity_logout() {
* @return null
*/
function serendipity_session_destroy() {
echo "session destroy";
$no_smarty = $_SESSION['no_smarty'];
$no_smarty = $_SESSION['no_smarty'] ?? null;
@session_destroy();
session_start();
session_regenerate_id();
@ -800,7 +799,7 @@ function serendipity_is_iframe() {
global $serendipity;
if ($serendipity['GET']['is_iframe'] ?? false && is_array($_SESSION['save_entry'])) {
if (!is_object($serendipity['smarty'])) {
if (!is_object($serendipity['smarty'] ?? null)) {
// We need smarty also in the iframe to load a template's config.inc.php and register possible event hooks.
serendipity_smarty_init();
}

View File

@ -41,7 +41,7 @@ function serendipity_fetchCategoryRange($categoryid) {
$res = array(array('category_left' => 0, 'category_right' => 0));
}
if ($res[0]['hide_sub'] == 1) {
if (($res[0]['hide_sub'] ?? null) == 1) {
// Set ranges only to own category. Patch by netmorix
return array('category_left' => $res[0]['category_left'], 'category_right' => $res[0]['category_left']);
} else {
@ -354,6 +354,9 @@ function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fe
}
serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('noCache' => $noCache, 'noSticky' => $noSticky, 'source' => 'entries'));
if (!isset($cond['addkey'])) {
$cond['addkey'] = '';
}
if (is_null($select_key)) {
$select_key = "{$cond['distinct']}
@ -394,6 +397,12 @@ function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fe
ON ec.categoryid = c.categoryid";
}
if (!isset($cond['joins'])) {
$cond['joins'] = '';
}
if (!isset($cond['and'])) {
$cond['and'] = '';
}
if ($joinown) {
$cond['joins'] .= $joinown;
}
@ -587,6 +596,9 @@ function &serendipity_fetchEntry($key, $val, $full = true, $fetchDrafts = 'false
$cond['single_orderby'] = '';
}
if (!isset($cond['joins'])) {
$cond['joins'] = '';
}
$querystring = "SELECT e.id,
e.title,
e.timestamp,
@ -894,6 +906,12 @@ function &serendipity_searchEntries($term, $limit = '', $searchresults = '') {
serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('source' => 'search', 'term' => $term));
serendipity_ACL_SQL($cond, 'limited');
if (!isset($cond['joins'])) {
$cond['joins'] = '';
}
if (!isset($cond['addkey'])) {
$cond['addkey'] = '';
}
$serendipity['fullCountQuery'] = "
FROM
{$serendipity['dbPrefix']}entries e
@ -1078,7 +1096,7 @@ function serendipity_getTotalEntries() {
function serendipity_printEntries($entries, $extended = 0, $preview = false, $smarty_block = 'ENTRIES', $smarty_fetch = true, $use_hooks = true, $use_footer = true, $use_grouped_array = false) {
global $serendipity;
if (!is_object($serendipity['smarty'])) {
if (!is_object($serendipity['smarty'] ?? null)) {
serendipity_smarty_init(); // if not set, start Smarty templating to avoid member function "method()" on a non-object errors (was draft preview error, now at line 1239)
}
@ -1113,17 +1131,22 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm
if ($use_grouped_array === false) {
// Use grouping by date (default)
$dategroup = array();
for ($x = 0, $num_entries = count($entries); $x < $num_entries; $x++) {
if (!empty($entries[$x]['properties']['ep_is_sticky']) && serendipity_db_bool($entries[$x]['properties']['ep_is_sticky'])) {
$entries[$x]['is_sticky'] = true;
$key = 'sticky';
} else {
$key = date('Ymd', serendipity_serverOffsetHour($entries[$x]['timestamp']));
}
$num_entries = count($entries);
foreach ($entries as $i => &$entry) {
if ($i !== 'id') {
if (!empty($entry['properties']['ep_is_sticky']) && serendipity_db_bool($entry['properties']['ep_is_sticky'])) {
$entry['is_sticky'] = true;
$key = 'sticky';
} else {
$key = date('Ymd', serendipity_serverOffsetHour($entry['timestamp']));
}
$dategroup[$key]['date'] = $entries[$x]['timestamp'];
$dategroup[$key]['is_sticky'] = (isset($entries[$x]['is_sticky']) && (serendipity_db_bool($entries[$x]['is_sticky']) ? true : false));
$dategroup[$key]['entries'][] = &$entries[$x];
$dategroup[$key]['date'] = $entry['timestamp'];
$dategroup[$key]['is_sticky'] = (isset($entry['is_sticky']) && (serendipity_db_bool($entry['is_sticky']) ? true : false));
$dategroup[$key]['entries'][] = &$entry;
} else {
$num_entries--;
}
}
} elseif ($use_grouped_array === 'plugin') {
// Let a plugin do the grouping
@ -1144,7 +1167,7 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm
}
if (!empty($entry['properties']['ep_cache_body'])) {
$entry['pre_body'] = $entry['body'];
$entry['pre_body'] = $entry['body'] ?? null;
$entry['body'] = &$entry['properties']['ep_cache_body'];
$entry['is_cached'] = true;
}
@ -1160,7 +1183,7 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm
}
if (!empty($entry['properties']['ep_cache_extended'])) {
$entry['pre_extended'] = $entry['extended'];
$entry['pre_extended'] = $entry['extended'] ?? null;
$entry['extended'] = &$entry['properties']['ep_cache_extended'];
$entry['is_cached'] = true;
}
@ -1721,7 +1744,7 @@ function serendipity_printArchives() {
ON e.id = ec.entryid
LEFT JOIN {$serendipity['dbPrefix']}category c
ON ec.categoryid = c.categoryid" : "") .
$sql_condition['joins'] .
($sql_condition['joins'] ?? '') .
" WHERE isdraft = 'false'"
. ($sql_condition['and'] ?? '')
. (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . serendipity_db_time() : '')

View File

@ -158,7 +158,7 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
$template_vars['entry_template'] = serendipity_getTemplateFile('admin/entries.tpl', 'serendipityPath');
if (!is_object($serendipity['smarty'])) {
if (!is_object($serendipity['smarty'] ?? null)) {
serendipity_smarty_init();
}
$serendipity['smarty']->registerPlugin('modifier', 'emit_htmlarea_code', 'serendipity_emit_htmlarea_code');

View File

@ -107,13 +107,12 @@ function serendipity_fetchImagesFromDatabase($start=0, $limit=0, &$total=null, $
$cond['parts']['keywords'] = " AND (mk.property IN ('" . serendipity_db_implode("', '", $keywords, 'string') . "'))\n";
$cond['joinparts']['keywords'] = true;
}
$cond['parts']['filter'] = '';
foreach($filter AS $f => $fval) {
if (! (isset($orderfields[$f]) || $f == "fileCategory") || empty($fval)) {
continue;
}
$cond['parts']['filter'] = '';
if (is_array($fval)) {
if (empty($fval['from']) || empty($fval['to'])) {
continue;
@ -187,6 +186,9 @@ function serendipity_fetchImagesFromDatabase($start=0, $limit=0, &$total=null, $
$cond['orderkey'] = "''";
}
if (!isset($cond['joins'])) {
$cond['joins'] = '';
}
if ($cond['joinparts']['properties'] ?? false) {
$cond['joins'] .= "\n LEFT OUTER JOIN {$serendipity['dbPrefix']}mediaproperties AS bp
ON (bp.mediaid = i.id AND bp.property_group = 'base_property' AND bp.property = '{$cond['orderproperty']}')\n";
@ -211,6 +213,9 @@ function serendipity_fetchImagesFromDatabase($start=0, $limit=0, &$total=null, $
$cond['distinct'] = '';
}
if (!isset($cond['joins'])) {
$cond['joins'] = '';
}
$basequery = "FROM {$serendipity['dbPrefix']}images AS i
LEFT OUTER JOIN {$serendipity['dbPrefix']}authors AS a
ON i.authorid = a.authorid
@ -283,6 +288,9 @@ function serendipity_fetchImageFromDatabase($id, $mode = 'read') {
serendipity_ACL_SQL($cond, false, 'directory', $mode);
}
if (!isset($cond['joins'])) {
$cond['joins'] = '';
}
$rs = serendipity_db_query("SELECT {$cond['distinct']} i.id, i.name, i.extension, i.mime, i.size, i.dimensions_width, i.dimensions_height, i.date, i.thumbnail_name, i.authorid, i.path, i.hotlink, i.realname
FROM {$serendipity['dbPrefix']}images AS i
{$cond['joins']}
@ -409,7 +417,7 @@ function serendipity_deleteImage($id) {
$dfnThumb = $file['path'] . $file['name'] . (!empty($thumb['fthumb']) ? '.' . $thumb['fthumb'] : '') . (empty($file['extension']) ? '' : '.' . $file['extension']);
$dfThumb = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $dfnThumb;
if (@unlink($dfThumb)) {
if (file_exists($dfThumb) && @unlink($dfThumb)) {
$messages .= sprintf('<span class="msg_success"><span class="icon-ok-circled" aria-hidden="true"></span> ' . DELETE_THUMBNAIL . "</span>\n", $dfnThumb);
}
}
@ -1233,6 +1241,9 @@ function serendipity_syncThumbs($deleteThumbs = false) {
AND extension = '" . serendipity_db_escape_string($f[1]) . "'"
);
serendipity_ACL_SQL($cond, false, 'directory');
if (!isset($cond['joins'])) {
$cond['joins'] = '';
}
$rs = serendipity_db_query("SELECT *
FROM {$serendipity['dbPrefix']}images AS i
@ -3202,8 +3213,8 @@ function serendipity_prepareMedia(&$file, $url = '') {
/* If it is an image, and the thumbnail exists */
if ($file['is_image'] && file_exists($file['full_thumb'])) {
$file['thumbWidth'] = $file['dim'][0];
$file['thumbHeight'] = $file['dim'][1];
$file['thumbWidth'] = $file['dim'][0] ?? null;
$file['thumbHeight'] = $file['dim'][1] ?? null;
} elseif ($file['is_image'] && $file['hotlink']) {
$sizes = serendipity_calculate_aspect_size($file['dimensions_width'], $file['dimensions_height'], $serendipity['thumbSize'], $serendipity['thumbConstraint']);
$file['thumbWidth'] = $sizes[0];
@ -3265,7 +3276,7 @@ function serendipity_showMedia(&$file, &$paths, $url = '', $manage = false, $lin
$form_hidden .= ' <input type="hidden" name="serendipity[adminModule]" value="media">'."\n";
}
if (!is_object($serendipity['smarty'])) {
if (!is_object($serendipity['smarty'] ?? null)) {
serendipity_smarty_init();
}
$order_fields = serendipity_getImageFields();

View File

@ -497,7 +497,7 @@ function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_nam
// I can't get it to work unless there's a class of
// pluginmanager_container on the ol, either.
// The drag-n-drop returns the list of IDs in order.
$data['sequencejs_output'] = $sequencejs_output = $serendipity['sequencejs_output'];
$data['sequencejs_output'] = $sequencejs_output = $serendipity['sequencejs_output'] ?? null;
if (!$sequencejs_output) {
$serendipity['sequencejs_output'] = true;
}

View File

@ -37,33 +37,35 @@ function locateHiddenVariables($_args) {
continue;
}
if ($v[0] == 'P') { /* Page */
$page = substr($v, 1);
if (is_numeric($page)) {
$serendipity['GET']['page'] = $page;
unset($_args[$k]);
unset($serendipity['uriArguments'][$k]);
}
} elseif ($v[0] == 'A') { /* Author */
$url_author = substr($v, 1);
if (is_numeric($url_author)) {
$serendipity['GET']['viewAuthor'] = (int)$url_author;
unset($_args[$k]);
}
} elseif ($v == 'summary') { /* Summary */
$serendipity['short_archives'] = true;
if (! array_key_exists('head_subtitle', $serendipity)) {
$serendipity['head_subtitle'] = '';
}
$serendipity['head_subtitle'] .= SUMMARY . ' - ';
unset($_args[$k]);
} elseif ($v[0] == 'C') { /* category */
$cat = substr($v, 1);
if (is_numeric($cat)) {
$serendipity['GET']['category'] = $cat;
unset($_args[$k]);
}
}
if (strlen($v) > 0) {
if ($v[0] == 'P') { /* Page */
$page = substr($v, 1);
if (is_numeric($page)) {
$serendipity['GET']['page'] = $page;
unset($_args[$k]);
unset($serendipity['uriArguments'][$k]);
}
} elseif ($v[0] == 'A') { /* Author */
$url_author = substr($v, 1);
if (is_numeric($url_author)) {
$serendipity['GET']['viewAuthor'] = (int)$url_author;
unset($_args[$k]);
}
} elseif ($v == 'summary') { /* Summary */
$serendipity['short_archives'] = true;
if (! array_key_exists('head_subtitle', $serendipity)) {
$serendipity['head_subtitle'] = '';
}
$serendipity['head_subtitle'] .= SUMMARY . ' - ';
unset($_args[$k]);
} elseif ($v[0] == 'C') { /* category */
$cat = substr($v, 1);
if (is_numeric($cat)) {
$serendipity['GET']['category'] = $cat;
unset($_args[$k]);
}
}
}
}
return $_args;
}
@ -396,14 +398,13 @@ function serveArchives() {
$serendipity['view'] = 'archives';
$_args = locateHiddenVariables($serendipity['uriArguments']);
/* We must always *assume* that Year, Month and Day are the first 3 arguments */
$year = $_args[0] ?? null;
$month = $_args[1] ?? null;
$day = $_args[2] ?? null;
if ($year == "archives") {
unset($year);
}
$year = $_args[1] ?? null;
$month = $_args[2] ?? null;
$day = $_args[3] ?? null;
//if ($year == "archives") {
// unset($year);
//}
$serendipity['GET']['action'] = 'read';
$serendipity['GET']['hidefooter'] = true;
@ -473,10 +474,13 @@ function serveArchives() {
$serendipity['range'] = array($ts, $te);
if ($serendipity['GET']['action'] == 'read') {
if ($serendipity['GET']['category']) {
if ($serendipity['GET']['category'] ?? false) {
$cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']);
$serendipity['head_title'] = $cInfo['category_name'];
}
if (!isset($serendipity['head_subtitle'])) {
$serendipity['head_subtitle'] = '';
}
$serendipity['head_subtitle'] .= sprintf(ENTRIES_FOR, $date);
}

View File

@ -284,19 +284,40 @@ function serendipity_smarty_fetchPrintEntries($params, $smarty) {
$serendipity['short_archives'] = $params['short_archives'];
}
$old_var['skip_smarty_hooks'] = $serendipity['skip_smarty_hooks'];
$old_var['skip_smarty_hooks'] = $serendipity['skip_smarty_hooks'] ?? null;
$serendipity['skip_smarty_hooks'] = $params['skip_smarty_hooks'];
$old_var['skip_smarty_hook'] = $serendipity['skip_smarty_hook'];
$old_var['skip_smarty_hook'] = $serendipity['skip_smarty_hook'] ?? null;
$serendipity['skip_smarty_hook'] = $params['skip_smarty_hook'];
foreach($restore_var_GET_keys AS $key) {
if (!empty($params[$key])) {
$old_var['GET'][$key] = $serendipity['GET'][$key];
$old_var['GET'][$key] = $serendipity['GET'][$key] ?? null;
$serendipity['GET'][$key] = $params[$key];
}
}
$param_keys = array(
'full',
'limit',
'fetchDrafts',
'modified_since',
'orderby',
'filter_sql',
'noCache',
'noSticky',
'select_key',
'group_by',
'returncode',
'joinauthors',
'joincategories',
'joinown'
);
foreach ($param_keys as $param_key) {
if (!isset($params[$param_key])) {
$params[$param_key] = null;
}
}
if (!empty($params['id'])) {
$entry = serendipity_fetchEntry(
'id',
@ -366,7 +387,7 @@ function serendipity_smarty_fetchPrintEntries($params, $smarty) {
$serendipity['short_archives'] = $old_var['short_archives'];
}
if (is_array($old_var['GET'])) {
if (is_array($old_var['GET'] ?? null)) {
foreach($old_var['GET'] AS $key => $val) {
$serendipity['GET'][$key] = $val;
}
@ -917,7 +938,9 @@ function serendipity_smarty_init($vars = array()) {
#@define('MEMCACHE_EXTENSION_LOADED', (class_exists('Memcached',false) || class_exists('Memcache',false)) && (extension_loaded("memcached") || extension_loaded("memcache")));
// Default Smarty Engine will be used
@define('SMARTY_DIR', S9Y_PEAR_PATH . 'Smarty/libs/');
if (!defined('SMARTY_DIR')) {
@define('SMARTY_DIR', S9Y_PEAR_PATH . 'Smarty/libs/');
}
if (!class_exists('Smarty')) {
include_once SMARTY_DIR . 'Smarty.class.php';
}

View File

@ -53,7 +53,7 @@ if (!defined('serendipity_MB_LOADED') && defined('serendipity_LANG_LOADED')) {
// Needs to be included here because we need access to constant LANG_CHARSET definied in languages (not available for compat.inc.php)
if (function_exists('mb_language')) {
@mb_language($serendipity['lang']);
@mb_language('uni'); // TODO: test for non-unicode installations
}
if (function_exists('mb_internal_encoding')) {

View File

@ -1,3 +1,4 @@
2.21.10: * hotfixes for PHP 8
2.21.7: * add some newlines in output to make it better humanly readable
2.21.6: * add missing 'u' inline element
2.21.5: * nl2p: if the double newline contains spaces, e.g. \n \n, these

View File

@ -18,7 +18,7 @@ class serendipity_event_nl2br extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_NL2BR_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Serendipity Team, Stephan Brunker');
$propbag->add('version', '2.21.9');
$propbag->add('version', '2.21.10');
$propbag->add('requirements', array(
'serendipity' => '1.6',
'smarty' => '2.6.7',
@ -344,7 +344,7 @@ class serendipity_event_nl2br extends serendipity_event
if( $isobr ) {
$serendipity['nl2br']['iso2br'] = true; // include to global as also used by staticpages now
if (! array_key_exists('smarty', $serendipity) || !is_object($serendipity['smarty'])) {
if (!is_object($serendipity['smarty'] ?? null)) {
serendipity_smarty_init(); // if not set to avoid member function assign() on a non-object error, start Smarty templating
}

View File

@ -0,0 +1,5 @@
1.8.1:
---
* hotfixes for PHP 8

View File

@ -19,7 +19,7 @@ class serendipity_event_xhtmlcleanup extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_XHTMLCLEANUP_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '1.8');
$propbag->add('version', '1.8.1');
$propbag->add('requirements', array(
'serendipity' => '1.6',
'smarty' => '2.6.7',
@ -143,7 +143,7 @@ class serendipity_event_xhtmlcleanup extends serendipity_event
$this->cleanup_parse = serendipity_db_bool($this->get_config('xhtml_parse', 'true'));
foreach ($this->markup_elements as $temp) {
if (serendipity_db_bool($this->get_config($temp['name'], 'true')) && isset($eventData[$temp['element']]) &&
!$eventData['properties']['ep_disable_markup_' . $this->instance] &&
(isset($eventData['properties']) && isset($eventData['properties']['ep_disable_markup_' . $this->instance]) && !$eventData['properties']['ep_disable_markup_' . $this->instance]) &&
!isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) {
$element = $temp['element'];
$this->cleanup_tag = 'IMG';

View File

@ -1,8 +1,13 @@
Version 1.17.1:
------------------------------------------------------------------------
* Fix: hotfixes for PHP 8
Version 1.17:
------------------------------------------------------------------------
* Fix: Don't strip HTML tags from comment body before truncating if
serendipity_event_unstrip_tags is active, so it may actually
preserve the tags (and replace them with entities).
Version 1.16:
------------------------------------------------------------------------
* Fix: wordwrap at word boundaries instead of "truncating" the lines

View File

@ -20,7 +20,7 @@ class serendipity_plugin_comments extends serendipity_plugin
$propbag->add('description', PLUGIN_COMMENTS_BLAHBLAH);
$propbag->add('stackable', true);
$propbag->add('author', 'Garvin Hicking, Tadashi Jokagi, Judebert, G. Brockhaus');
$propbag->add('version', '1.17');
$propbag->add('version', '1.17.1');
$propbag->add('requirements', array(
'serendipity' => '1.6',
'smarty' => '2.6.7',
@ -166,6 +166,9 @@ class serendipity_plugin_comments extends serendipity_plugin
serendipity_ACL_SQL($cond, true);
serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('source' => 'entries'));
}
if (!isset($cond['joins'])) {
$cond['joins'] = '';
}
$q = 'SELECT co.body AS comment,
co.timestamp AS stamp,

View File

@ -244,7 +244,7 @@ if ($ajax) {
$admin_vars['version_info'] = sprintf(ADMIN_FOOTER_POWERED_BY, '', '');
}
if (!is_object($serendipity['smarty'])) {
if (!is_object($serendipity['smarty'] ?? null)) {
serendipity_smarty_init();
}
$serendipity['smarty']->assignByRef('admin_vars', $admin_vars);

View File

@ -17,7 +17,7 @@
{/if}
{if $doDelete}
{if $deleteSuccess}
<span class="msg_success"><span class="icon-ok-circled" aria-hidden="true"></span> {if $remainingCat}{$CONST.CATEGORY_DELETED_ARTICLES_MOVED|sprintf:$remainingCat:$cid}{else}{$cid|string_format:"{$CONST.CATEGORY_DELETED}"}{/if}</span>
<span class="msg_success"><span class="icon-ok-circled" aria-hidden="true"></span> {if isset($remainingCat) && $remainingCat}{$CONST.CATEGORY_DELETED_ARTICLES_MOVED|sprintf:$remainingCat:$cid}{else}{$cid|string_format:"{$CONST.CATEGORY_DELETED}"}{/if}</span>
{else}
<span class="msg_error"><span class="icon-attention-circled" aria-hidden="true"></span> {$CONST.INVALID_CATEGORY}</span>
{/if}
@ -74,7 +74,7 @@
<option value="0"{if $cid == 0} selected{/if}>{$CONST.NO_CATEGORY}</option>
{foreach $categories as $cat}
{if $cat.categoryid == $cid}{continue}{/if}
<option value="{$cat.categoryid}"{if $this_cat.parentid == $cat.categoryid} selected{/if}>{for $i=1 to $cat.depth}&nbsp{/for} {$cat.category_name|escape}</option>
<option value="{$cat.categoryid}"{if isset($this_cat.parentid) && $this_cat.parentid == $cat.categoryid} selected{/if}>{for $i=1 to $cat.depth}&nbsp{/for} {$cat.category_name|escape}</option>
{/foreach}
</select>
</div>

View File

@ -133,7 +133,7 @@
<dt>{$CONST.AUTHOR}:</dt>
<dd>{$comment.author|escape|truncate:40:"&hellip;"} {$comment.action_author}</dd>
<dt>{$CONST.EMAIL}:</dt>
<dd>{if empty($comment.email)}N/A{else}<a href="mailto:{$comment.email|escape}" title="{$comment.email|escape}">{$comment.email|escape|truncate:40:"&hellip;"}</a>{if $comment.subscribed == 'true'} <i>({$CONST.ACTIVE_COMMENT_SUBSCRIPTION})</i>{/if}{/if} {$comment.action_email}</dd>
<dd>{if empty($comment.email)}N/A{else}<a href="mailto:{$comment.email|escape}" title="{$comment.email|escape}">{$comment.email|escape|truncate:40:"&hellip;"}</a>{if $comment.subscribed == 'true'} <i>({$CONST.ACTIVE_COMMENT_SUBSCRIPTION})</i>{/if}{/if} {if isset($comment.action_email)}{$comment.action_email}{/if}</dd>
<dt>IP:</dt>
<dd>{if empty($comment.ip)}N/A{else}{$comment.ip|escape}{/if} {if isset($comment.action_ip)}{$comment.action_ip}{/if}</dd>
<dt>URL:</dt>
@ -189,4 +189,4 @@
</div>
</form>
{/if}
{/if}
{/if}

View File

@ -1,12 +1,12 @@
<h2>{$CONST.CONFIGURATION}</h2>
{if $installAction == 'check'}
{if $diagnosticError}
{if isset($diagnosticError) && $diagnosticError}
<h2>{$CONST.DIAGNOSTIC_ERROR}</h2>
{foreach $res as $r}
<span class="msg_error"><span class="icon-attention-circled" aria-hidden="true"></span> {$r}</span>
{/foreach}
{else}
{if $htaccessRewrite}
{if isset($htaccessRewrite) && $htaccessRewrite}
<h2>{$CONST.ATTEMPT_WRITE_FILE|sprintf:"{$serendipityPath}htaccess"}</h2>
{if is_array($res)}
{foreach $res as $r}
@ -19,4 +19,4 @@
<span class="msg_success"><span class="icon-ok-circled" aria-hidden="true"></span> {$CONST.WRITTEN_N_SAVED}</span>
{/if}
{/if}
{$config}
{$config}

View File

@ -15,7 +15,7 @@
{$img_alt="{$file.realname}"}
{elseif $file.is_image AND $file.hotlink}
{if $media.textarea}
{if (isset($media.textarea) && $media.textarea)}
{$link="?serendipity[adminModule]=images&amp;serendipity[adminAction]=choose&amp;serendipity[fid]={$file.id}&amp;serendipity[textarea]={$media.textarea}&amp;serendipity[noBanner]=true&amp;serendipity[noSidebar]=true&amp;serendipity[noFooter]=true&amp;serendipity[filename_only]={$media.filename_only}&amp;serendipity[htmltarget]={$media.htmltarget}"}
{else}
{if $file.url}
@ -26,7 +26,7 @@
{$img_title="{$file.path}"}
{$img_alt="{$file.realname}"}
{else}
{if $media.textarea}
{if (isset($media.textarea) && $media.textarea)}
{$link="?serendipity[adminModule]=images&amp;serendipity[adminAction]=choose&amp;serendipity[fid]={$file.id}&amp;serendipity[textarea]={$media.textarea}&amp;serendipity[noBanner]=true&amp;serendipity[noSidebar]=true&amp;serendipity[noFooter]=true&amp;serendipity[filename_only]={$media.filename_only}&amp;serendipity[htmltarget]={$media.htmltarget}"}
{else}
{if $file.url}

View File

@ -50,46 +50,52 @@
{foreach $media.sort_order AS $filtername => $filter}
<div class="{cycle values="left,center,right"}{if $filter@iteration > 6} bp_filters{/if}">
{if $filter.type == 'date' || $filter.type == 'intrange'}
{if isset($filter.type) && ($filter.type == 'date' || $filter.type == 'intrange')}
<fieldset>
<span class="wrap_legend"><legend>{$filter.desc}</legend></span>
{else}
<div class="form_{if $filter.type == 'authors'}select{else}field{/if}">
<div class="form_{if isset($filter.type) && $filter.type == 'authors'}select{else}field{/if}">
<label for="serendipity_filter_{$filter@key}">{$filter.desc}</label>
{/if}
{if $filter.type == 'date'}
{if isset($filter.type)}
{if $filter.type == 'date'}
<div class="form_field">
<label for="serendipity_filter_{$filter@key}_from" class="range-label">{$CONST.RANGE_FROM|lower}</label>
<input id="serendipity_filter_{$filter@key}_from" name="serendipity[filter][{$filter@key}][from]" type="date" placeholder="2001-01-31" value="{if isset($media.filter[$filter@key].from)}{$media.filter[$filter@key].from|escape}{/if}">
<label for="serendipity_filter_{$filter@key}_to" class="range-label">{$CONST.RANGE_TO|lower}</label>
<input id="serendipity_filter_{$filter@key}_to" name="serendipity[filter][{$filter@key}][to]" type="date" placeholder="2005-12-31" value="{if isset($media.filter[$filter@key].to)}{$media.filter[$filter@key].to|escape}{/if}">
</div>
{elseif $filter.type == 'intrange'}
<div class="form_field">
<label for="serendipity_filter_{$filter@key}_from" class="range-label">{$CONST.RANGE_FROM|lower}</label>
<input id="serendipity_filter_{$filter@key}_from" name="serendipity[filter][{$filter@key}][from]" type="date" placeholder="2001-01-31" value="{if isset($media.filter[$filter@key].from)}{$media.filter[$filter@key].from|escape}{/if}">
<label for="serendipity_filter_{$filter@key}_to" class="range-label">{$CONST.RANGE_TO|lower}</label>
<input id="serendipity_filter_{$filter@key}_to" name="serendipity[filter][{$filter@key}][to]" type="date" placeholder="2005-12-31" value="{if isset($media.filter[$filter@key].to)}{$media.filter[$filter@key].to|escape}{/if}">
</div>
{elseif $filter.type == 'intrange'}
<div class="form_field">
<label for="serendipity_filter_{$filter@key}_from" class="range-label">{$CONST.RANGE_FROM|lower}</label>
<input id="serendipity_filter_{$filter@key}_from" name="serendipity[filter][{$filter@key}][from]" type="text" placeholder="{if $filtername == 'bp.RUN_LENGTH'}in{/if}" value="{if isset($media.filter[$filter@key].from)}{$media.filter[$filter@key].from|escape}{/if}">
<label for="serendipity_filter_{$filter@key}_to" class="range-label">{$CONST.RANGE_TO|lower}</label>
<input id="serendipity_filter_{$filter@key}_to" name="serendipity[filter][{$filter@key}][to]" type="text" placeholder="{if $filtername == 'bp.RUN_LENGTH'}seconds{/if}" value="{if isset($media.filter[$filter@key].to)}{$media.filter[$filter@key].to|escape}{/if}">
</div>
{elseif $filter.type == 'authors'}
<div class="form_field">
<label for="serendipity_filter_{$filter@key}_from" class="range-label">{$CONST.RANGE_FROM|lower}</label>
<input id="serendipity_filter_{$filter@key}_from" name="serendipity[filter][{$filter@key}][from]" type="text" placeholder="{if $filtername == 'bp.RUN_LENGTH'}in{/if}" value="{if isset($media.filter[$filter@key].from)}{$media.filter[$filter@key].from|escape}{/if}">
<label for="serendipity_filter_{$filter@key}_to" class="range-label">{$CONST.RANGE_TO|lower}</label>
<input id="serendipity_filter_{$filter@key}_to" name="serendipity[filter][{$filter@key}][to]" type="text" placeholder="{if $filtername == 'bp.RUN_LENGTH'}seconds{/if}" value="{if isset($media.filter[$filter@key].to)}{$media.filter[$filter@key].to|escape}{/if}">
</div>
{elseif $filter.type == 'authors'}
<select id="serendipity_filter_{$filter@key}" name="serendipity[filter][{$filter@key}]">
<option value="">{$CONST.ALL_AUTHORS}</option>
{foreach $media.authors AS $media_author}
<select id="serendipity_filter_{$filter@key}" name="serendipity[filter][{$filter@key}]">
<option value="">{$CONST.ALL_AUTHORS}</option>
{foreach $media.authors AS $media_author}
<option value="{$media_author.authorid}"{if isset($media.filter[$filter@key]) and $media.filter[$filter@key] == $media_author.authorid} selected{/if}>{$media_author.realname|escape}</option>
{/foreach}
<option value="{$media_author.authorid}"{if isset($media.filter[$filter@key]) and $media.filter[$filter@key] == $media_author.authorid} selected{/if}>{$media_author.realname|escape}</option>
{/foreach}
</select>
</select>
{else}{* this is of type string w/o being named *}
{* label is already set on loop start, when type is not date or intrange *}
<input id="serendipity_filter_{$filter@key}" name="serendipity[filter][{$filter@key}]" type="text" value="{if isset($media.filter[$filter@key])}{$media.filter[$filter@key]|escape}{/if}">
{/if}
{else}{* this is of type string w/o being named *}
{* label is already set on loop start, when type is not date or intrange *}
<input id="serendipity_filter_{$filter@key}" name="serendipity[filter][{$filter@key}]" type="text" value="{if isset($media.filter[$filter@key])}{$media.filter[$filter@key]|escape}{/if}">
{/if}
{if $filter.type == 'date' || $filter.type == 'intrange'}
{if isset($filter.type) && ($filter.type == 'date' || $filter.type == 'intrange')}
</fieldset>
{else}

View File

@ -1,4 +1,5 @@
{serendipity_hookPlugin hook="entries_header" addData="$entry_id"}
{if isset($entries)}
{foreach from=$entries item="dategroup"}
{foreach from=$dategroup.entries item="entry"}
{assign var="entry" value=$entry scope="parent"}
@ -137,6 +138,11 @@
<p class="nocontent">{$CONST.NO_ENTRIES_TO_PRINT}</p>
{/if}
{/foreach}
{else}
{if isset($plugin_clean_page) and not $plugin_clean_page}
<p class="nocontent">{$CONST.NO_ENTRIES_TO_PRINT}</p>
{/if}
{/if}
{if isset($footer_info) and $footer_info or isset($footer_prev_page) and $footer_prev_page or isset($footer_next_page) and $footer_next_page}
<nav class="serendipity_pagination block_level">
<h2 class="visuallyhidden">{$CONST.TWOK11_PAG_TITLE}</h2>
@ -150,4 +156,4 @@
</ul>
</nav>
{/if}
{serendipity_hookPlugin hook="entries_footer"}
{serendipity_hookPlugin hook="entries_footer"}