From f122271061b504c8756385802c8bef5f0fd12b7e Mon Sep 17 00:00:00 2001 From: Sama34 Date: Tue, 13 Aug 2024 08:19:02 -0700 Subject: [PATCH] Fix PHP warnings & fatal errors --- resources/class_cache_handler.php | 4 ++-- resources/functions.php | 19 +------------------ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/resources/class_cache_handler.php b/resources/class_cache_handler.php index 3a4bde2..898d9a3 100644 --- a/resources/class_cache_handler.php +++ b/resources/class_cache_handler.php @@ -337,7 +337,7 @@ function fid($old_fid) $this->cache_forums(); } - return $this->cache_fids[$old_fid]; + return isset($this->cache_fids[$old_fid]) ? $this->cache_fids[$old_fid] : 0; } /** @@ -448,7 +448,7 @@ function tid($old_tid) $this->cache_threads(); } - return $this->cache_tids[$old_tid]; + return isset($this->cache_tids[$old_tid]) ? $this->cache_tids[$old_tid] : 0; } /** diff --git a/resources/functions.php b/resources/functions.php index bb7cd71..980fff6 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -255,28 +255,11 @@ function delete_import_fields($text=true) $progress += $increment; } - $columns_to_drop = array(); foreach($columns as $column) { if($db->field_exists($column, $table)) { - $columns_to_drop[] = $column; - } - } - if(!empty($columns_to_drop)) - { - if($db->type == "sqlite") - { - // Can be achieved in a transaction if we'd finally support it. - foreach($columns_to_drop as $column) - { - $db->write_query("ALTER TABLE ".TABLE_PREFIX.$table." DROP {$column}"); - } - } - else - { - $columns_sql = implode(", DROP ", $columns_to_drop); - $db->write_query("ALTER TABLE ".TABLE_PREFIX.$table." DROP {$columns_sql}"); + $db->drop_column($table, $column); } } }