From 1223840b4aa04a4511c3d27250d602881f65d7bd Mon Sep 17 00:00:00 2001 From: Jari Turkia Date: Tue, 8 Oct 2024 22:58:14 +0300 Subject: [PATCH 1/8] bugfix: pg_escape_string() in serendipity_db_escape_string() works again --- include/db/postgres.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/db/postgres.inc.php b/include/db/postgres.inc.php index ec32b3831..12ac0c335 100644 --- a/include/db/postgres.inc.php +++ b/include/db/postgres.inc.php @@ -89,7 +89,9 @@ function serendipity_db_reconnect() { * @return string output string */ function serendipity_db_escape_string($string) { - return pg_escape_string($string); + global $serendipity; + + return pg_escape_string($serendipity['dbConn'], $string); } /** From 521ac7b0067f5ae30a72d2a3436e29abce428c69 Mon Sep 17 00:00:00 2001 From: Jari Turkia Date: Sun, 13 Oct 2024 14:18:29 +0300 Subject: [PATCH 2/8] bugfix: Avoid escaping a NULL value --- include/db/postgres.inc.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/db/postgres.inc.php b/include/db/postgres.inc.php index 12ac0c335..e13e15aaa 100644 --- a/include/db/postgres.inc.php +++ b/include/db/postgres.inc.php @@ -91,6 +91,9 @@ function serendipity_db_reconnect() { function serendipity_db_escape_string($string) { global $serendipity; + if (is_null($string)) + return $string; + return pg_escape_string($serendipity['dbConn'], $string); } From 1ee316bb7037a44f25208cee040a18a69bfc169a Mon Sep 17 00:00:00 2001 From: Jari Turkia Date: Sun, 13 Oct 2024 21:43:58 +0300 Subject: [PATCH 3/8] feat: Added support for already obsoleted PHP-versions with PostgreSQL --- include/db/postgres.inc.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/db/postgres.inc.php b/include/db/postgres.inc.php index e13e15aaa..363503ca6 100644 --- a/include/db/postgres.inc.php +++ b/include/db/postgres.inc.php @@ -94,6 +94,11 @@ function serendipity_db_escape_string($string) { if (is_null($string)) return $string; + if (PHP_MAJOR_VERSION < 8 || (PHP_MAJOR_VERSION == 8 && PHP_MINOR_VERSION < 1)) + # Last supported version is PHP 8.0 + return pg_escape_string($string); + + # From PHP 8.1 onwards return pg_escape_string($serendipity['dbConn'], $string); } From 25f3d7b9f3eacc613cb03d60def24e4bf96f0d17 Mon Sep 17 00:00:00 2001 From: Jari Turkia Date: Mon, 14 Oct 2024 19:53:22 +0300 Subject: [PATCH 4/8] feat: Improved PHP version detection as suggested by onli --- include/db/postgres.inc.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/db/postgres.inc.php b/include/db/postgres.inc.php index 363503ca6..687c626f9 100644 --- a/include/db/postgres.inc.php +++ b/include/db/postgres.inc.php @@ -94,9 +94,10 @@ function serendipity_db_escape_string($string) { if (is_null($string)) return $string; - if (PHP_MAJOR_VERSION < 8 || (PHP_MAJOR_VERSION == 8 && PHP_MINOR_VERSION < 1)) - # Last supported version is PHP 8.0 + if (version_compare(PHP_VERSION, '8.1.0', '<')) { + # Versions before 8.1 give the connection by default return pg_escape_string($string); + } # From PHP 8.1 onwards return pg_escape_string($serendipity['dbConn'], $string); From 5c75b730fb836def4936c1fe56b2c0d76665f20e Mon Sep 17 00:00:00 2001 From: Jari Turkia Date: Mon, 14 Oct 2024 20:13:22 +0300 Subject: [PATCH 5/8] feat: PHP 8.2 won't do NULLs in str_replace() --- include/functions_permalinks.inc.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/functions_permalinks.inc.php b/include/functions_permalinks.inc.php index afeb41c9b..709979b5d 100644 --- a/include/functions_permalinks.inc.php +++ b/include/functions_permalinks.inc.php @@ -10,12 +10,16 @@ * Converts a string into a filename that can be used safely in HTTP URLs * * @access public - * @param string input string + * @param string input string|null * @param boolean Shall dots in the filename be removed? (Required for certain regex rules) - * @return string output string + * @return string output string|null */ function serendipity_makeFilename($str, $stripDots = false) { + if (is_null($str)) { + return $str; + } + // These are UTF-8 replacements happening regardless of selected locale static $pre_from = array( '🇦', From 81d65b76220a9b750565cefc9fd3d809e2f1832a Mon Sep 17 00:00:00 2001 From: Jari Turkia Date: Mon, 14 Oct 2024 20:48:34 +0300 Subject: [PATCH 6/8] feat: Maintenance won't use deprecated strftime() anymore --- include/admin/maintenance.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/admin/maintenance.inc.php b/include/admin/maintenance.inc.php index 1f5384c86..18c6834cc 100644 --- a/include/admin/maintenance.inc.php +++ b/include/admin/maintenance.inc.php @@ -65,7 +65,7 @@ $data['maintenance_mode'] = serendipity_db_bool(serendipity_get_config_var("maintenanceMode", false)); -$data['maintenance_mode_end'] = strftime('%d.%m.%y %T', serendipity_get_config_var("maintenanceModeEnd")); +$data['maintenance_mode_end'] = date('j.n.Y e', serendipity_get_config_var("maintenanceModeEnd")); $data['maintenance_mode_active'] = $data['maintenance_mode'] && time() < serendipity_get_config_var("maintenanceModeEnd", 0); # php 8 compat section From 160dbdacd89b45f1d9d0d81fb87f6744a0f76ae3 Mon Sep 17 00:00:00 2001 From: Jari Turkia Date: Mon, 14 Oct 2024 20:54:19 +0300 Subject: [PATCH 7/8] feat: Entry preview doesn't use dynamic property --- .../serendipity_event_entryproperties.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php index 4dedada70..54348d7fa 100644 --- a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php +++ b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php @@ -878,7 +878,8 @@ function event_hook($event, &$bag, &$eventData, $addData = null) } } - if ($addData['preview'] && is_array($serendipity['POST']['properties']) && count($serendipity['POST']['properties']) > 0){ + if ($addData['preview'] && isset($serendipity['POST']['properties']) && + is_array($serendipity['POST']['properties']) && count($serendipity['POST']['properties']) > 0){ $parr = array(); $supported_properties = serendipity_event_entryproperties::getSupportedProperties(); foreach($supported_properties AS $prop_key) { From 14d546b6473faf86eb1c2fc07fe0d58ded2ae9ce Mon Sep 17 00:00:00 2001 From: Jari Turkia Date: Mon, 14 Oct 2024 21:16:05 +0300 Subject: [PATCH 8/8] feat: Made publich entry working on PHP 8.2 --- include/functions_entries.inc.php | 7 +++++-- templates/2k11/admin/overview.inc.tpl | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/functions_entries.inc.php b/include/functions_entries.inc.php index 523281e72..5b58c8f8d 100644 --- a/include/functions_entries.inc.php +++ b/include/functions_entries.inc.php @@ -1390,13 +1390,16 @@ function serendipity_updertEntry($entry) { serendipity_plugin_api::hook_event('backend_entry_presave', $entry); - $categories = $entry['categories']; + $categories = $entry['categories'] ?? null; unset($entry['categories']); if (array_key_exists('had_categories', $entry)) { $had_categories = $entry['had_categories']; unset($entry['had_categories']); } + else { + $had_categories = null; + } $newEntry = 0; $exflag = 0; @@ -1414,7 +1417,7 @@ function serendipity_updertEntry($entry) { $entry['extended'] = ''; } - if (strlen($entry['extended'])) { + if (isset($entry['extended']) && strlen($entry['extended'])) { $exflag = 1; } diff --git a/templates/2k11/admin/overview.inc.tpl b/templates/2k11/admin/overview.inc.tpl index 0f5775b72..ebd0ef9b0 100644 --- a/templates/2k11/admin/overview.inc.tpl +++ b/templates/2k11/admin/overview.inc.tpl @@ -88,7 +88,7 @@ - {if !$showFutureEntries && ($entry.timestamp >= $serverOffsetHour) && $entry.isdraft == "false"} + {if !$showFutureEntries && ($entry.timestamp >= $serverOffsetHour) && $entry.isdraft[0] == "f"} {$entry.timestamp|formatTime:$CONST.DATE_FORMAT_SHORT} {/if} {if isset($entry.properties.ep_is_sticky) && $entry.properties.ep_is_sticky} {$CONST.STICKY_POSTINGS} {/if} - {if $entry.isdraft == "true"} + {if $entry.isdraft[0] == "t"} {$CONST.DRAFT} {/if}