diff --git a/ext/source_history/main.php b/ext/source_history/main.php index cbfccb69a..22b5d9186 100644 --- a/ext/source_history/main.php +++ b/ext/source_history/main.php @@ -4,8 +4,6 @@ namespace Shimmie2; -use function MicroHTML\{rawHTML}; - class SourceHistory extends Extension { /** @var SourceHistoryTheme */ @@ -170,7 +168,7 @@ private function process_revert_request(int $revert_id): void $page->set_redirect(make_link('post/view/'.$stored_image_id)); } - protected function process_bulk_revert_request(): void + private function process_bulk_revert_request(): void { if (isset($_POST['revert_name']) && !empty($_POST['revert_name'])) { $revert_name = $_POST['revert_name']; @@ -212,7 +210,7 @@ protected function process_bulk_revert_request(): void /** * @return array|null */ - public function get_source_history_from_revert(int $revert_id): ?array + private function get_source_history_from_revert(int $revert_id): ?array { global $database; $row = $database->get_row(" @@ -226,7 +224,7 @@ public function get_source_history_from_revert(int $revert_id): ?array /** * @return array */ - public function get_source_history_from_id(int $image_id): array + private function get_source_history_from_id(int $image_id): array { global $database; return $database->get_all( @@ -243,7 +241,7 @@ public function get_source_history_from_id(int $image_id): array /** * @return array */ - public function get_global_source_history(int $page_id): array + private function get_global_source_history(int $page_id): array { global $database; return $database->get_all(" @@ -258,7 +256,7 @@ public function get_global_source_history(int $page_id): array /** * This function attempts to revert all changes by a given IP within an (optional) timeframe. */ - public function process_revert_all_changes(?string $name, ?string $ip, ?string $date): void + private function process_revert_all_changes(?string $name, ?string $ip, ?string $date): void { global $database; @@ -327,11 +325,7 @@ public function process_revert_all_changes(?string $name, ?string $ip, ?string $ log_debug("source_history", 'Reverting source of >>'.$stored_image_id.' to ['.$stored_source.']'); - $image = Image::by_id($stored_image_id); - - if (is_null($image)) { - die('Error: No image with the id ('.$stored_image_id.') was found. Perhaps the image was deleted while processing this request.'); - } + $image = Image::by_id_ex($stored_image_id); // all should be ok so we can revert by firing the SetSources event. send_event(new SourceSetEvent($image, $stored_source)); diff --git a/ext/tag_history/main.php b/ext/tag_history/main.php index 2a498a241..a2b5e0b7a 100644 --- a/ext/tag_history/main.php +++ b/ext/tag_history/main.php @@ -4,8 +4,6 @@ namespace Shimmie2; -use function MicroHTML\rawHTML; - class TagHistory extends Extension { /** @var TagHistoryTheme */ @@ -216,7 +214,7 @@ private function process_revert_request(int $revert_id): void $page->set_redirect(make_link('post/view/'.$stored_image_id)); } - protected function process_bulk_revert_request(): void + private function process_bulk_revert_request(): void { if (isset($_POST['revert_name']) && !empty($_POST['revert_name'])) { $revert_name = $_POST['revert_name']; @@ -258,7 +256,7 @@ protected function process_bulk_revert_request(): void /** * @return array|null */ - public function get_tag_history_from_revert(int $revert_id): ?array + private function get_tag_history_from_revert(int $revert_id): ?array { global $database; $row = $database->get_row(" @@ -272,7 +270,7 @@ public function get_tag_history_from_revert(int $revert_id): ?array /** * @return array */ - public function get_tag_history_from_id(int $image_id): array + private function get_tag_history_from_id(int $image_id): array { global $database; return $database->get_all( @@ -289,7 +287,7 @@ public function get_tag_history_from_id(int $image_id): array /** * @return array */ - public function get_global_tag_history(int $page_id): array + private function get_global_tag_history(int $page_id): array { global $database; return $database->get_all(" @@ -304,7 +302,7 @@ public function get_global_tag_history(int $page_id): array /** * @return array|null */ - public function get_previous_tags(int $image_id, int $id): ?array + public static function get_previous_tags(int $image_id, int $id): ?array { global $database; $row = $database->get_row(" @@ -320,7 +318,7 @@ public function get_previous_tags(int $image_id, int $id): ?array /** * This function attempts to revert all changes by a given IP within an (optional) timeframe. */ - public function process_revert_all_changes(?string $name, ?string $ip, ?string $date): void + private function process_revert_all_changes(?string $name, ?string $ip, ?string $date): void { global $database; @@ -388,9 +386,8 @@ public function process_revert_all_changes(?string $name, ?string $ip, ?string $ $stored_tags = $result['tags']; $image = Image::by_id($stored_image_id); - if (!$image instanceof Image) { + if (is_null($image)) { continue; - //throw new ImageDoesNotExist("Error: cannot find any image with the ID = ". $stored_image_id); } log_debug("tag_history", 'Reverting tags of >>'.$stored_image_id.' to ['.$stored_tags.']'); diff --git a/ext/tag_history/theme.php b/ext/tag_history/theme.php index b3f582528..7d6be5718 100644 --- a/ext/tag_history/theme.php +++ b/ext/tag_history/theme.php @@ -131,8 +131,7 @@ protected function history_entry(array $fields, bool $selected): string : null; $setter = A(["href" => make_link("user/" . url_escape($name))], $name); - $th = new TagHistory(); - $pt = $th->get_previous_tags($image_id, $current_id); + $pt = TagHistory::get_previous_tags($image_id, $current_id); if ($pt) { $previous_tags = explode(" ", $pt["tags"]); }