From 10ca416f0eae296fe009ba5c96f0798a49530ef5 Mon Sep 17 00:00:00 2001 From: danpros Date: Thu, 23 Nov 2023 19:37:53 +0700 Subject: [PATCH] Clean up PHP error log --- system/admin/admin.php | 6 +++--- system/htmly.php | 26 ++++++++++++++++---------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/system/admin/admin.php b/system/admin/admin.php index 951332b..15929fd 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -120,7 +120,7 @@ function add_content($title, $tag, $url, $content, $user, $draft, $category, $ty $post_date = date('Y-m-d-H-i-s'); $post_title = safe_html($title); - $post_media = preg_replace('/\s\s+/', ' ', strip_tags($media)); + $post_media = preg_replace('/\s\s+/', ' ', strip_tags($media ?? '')); $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($post_tag))); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); $description = safe_html($description); @@ -260,7 +260,7 @@ function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publ } $post_title = safe_html($title); - $post_media = preg_replace('/\s\s+/', ' ', strip_tags($media)); + $post_media = preg_replace('/\s\s+/', ' ', strip_tags($media ?? '')); $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($post_tag))); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); $description = safe_html($description); @@ -408,7 +408,7 @@ function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publ save_tag_i18n($post_tag, $post_tagmd); rebuilt_cache('all'); - clear_post_cache($dt, $post_tag, $post_url, $newfile, $category, $type); + clear_post_cache($dt, $post_tag, $post_url, $oldfile, $category, $type); if ($destination == 'post') { if(!empty($revertPost)) { $drafturl = site_url() . 'admin/draft'; diff --git a/system/htmly.php b/system/htmly.php index bcb4d8f..286f5d3 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -1736,7 +1736,9 @@ get('/category/:category', function ($category) { $desc = get_category_info($category); if(strtolower($category) !== 'uncategorized') { - $desc = $desc[0]; + if(!empty($desc)) { + $desc = $desc[0]; + } } $total = get_categorycount($category); @@ -2224,7 +2226,11 @@ get('/post/:name', function ($name) { if (config('permalink.type') != 'post') { $post = find_post(null, null, $name); - $current = $post['current']; + if (is_null($post)) { + not_found(); + } else { + $current = $post['current']; + } $redir = site_url() . date('Y/m', $current->date) . '/' . $name; header("location: $redir", TRUE, 301); } @@ -2237,11 +2243,11 @@ get('/post/:name', function ($name) { $post = find_post(null, null, $name); - $current = $post['current']; - - if (!$current) { + if (is_null($post)) { not_found(); - } + } else { + $current = $post['current']; + } if (config("views.counter") == "true") { add_view($current->file); @@ -3230,11 +3236,11 @@ get('/:year/:month/:name', function ($year, $month, $name) { $post = find_post($year, $month, $name); - $current = $post['current']; - - if (!$current) { + if (is_null($post)) { not_found(); - } + } else { + $current = $post['current']; + } if (config("views.counter") == "true") { add_view($current->file);