diff --git a/ext/approval/main.php b/ext/approval/main.php index cf83ff0a..1f6216c0 100644 --- a/ext/approval/main.php +++ b/ext/approval/main.php @@ -121,7 +121,7 @@ class Approval extends Extension const SEARCH_REGEXP = "/^approved:(yes|no)/"; public function onSearchTermParse(SearchTermParseEvent $event) { - global $user, $database, $config; + global $user, $config; if ($config->get_bool(ApprovalConfig::IMAGES)) { $matches = []; diff --git a/ext/auto_tagger/main.php b/ext/auto_tagger/main.php index c534ebbf..11782cb9 100644 --- a/ext/auto_tagger/main.php +++ b/ext/auto_tagger/main.php @@ -314,14 +314,10 @@ class AutoTagger extends Extension $tags_mixed = array_merge($tags_mixed, $new_tags); } - $results = array_intersect_key( + return array_intersect_key( $tags_mixed, array_unique(array_map('strtolower', $tags_mixed)) ); - - - - return $results; } /** diff --git a/ext/bulk_actions/main.php b/ext/bulk_actions/main.php index a81adb31..3c317f01 100644 --- a/ext/bulk_actions/main.php +++ b/ext/bulk_actions/main.php @@ -193,14 +193,14 @@ class BulkActions extends Extension if (is_iterable($items)) { send_event($bae); } + + if ($bae->redirect) { + $page->set_mode(PageMode::REDIRECT); + $page->set_redirect(referer_or(make_link())); + } } catch (BulkActionException $e) { log_error(BulkActionsInfo::KEY, $e->getMessage(), $e->getMessage()); } - - if ($bae->redirect) { - $page->set_mode(PageMode::REDIRECT); - $page->set_redirect(referer_or(make_link())); - } } } diff --git a/ext/bulk_add/test.php b/ext/bulk_add/test.php index 48dad449..c34c8b93 100644 --- a/ext/bulk_add/test.php +++ b/ext/bulk_add/test.php @@ -6,7 +6,7 @@ class BulkAddTest extends ShimmiePHPUnitTestCase { send_event(new UserLoginEvent(User::by_name(self::$admin_name))); $bae = send_event(new BulkAddEvent('asdf')); - $this->assertContains( + $this->assertContainsEquals( "Error, asdf is not a readable directory", $bae->results, implode("\n", $bae->results) diff --git a/ext/bulk_download/main.php b/ext/bulk_download/main.php index 547e2aff..28ff60e9 100644 --- a/ext/bulk_download/main.php +++ b/ext/bulk_download/main.php @@ -21,7 +21,7 @@ class BulkDownload extends Extension public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event) { - global $user, $config; + global $user; if ($user->can(Permissions::BULK_DOWNLOAD)) { $event->add_action(BulkDownload::DOWNLOAD_ACTION_NAME, "Download ZIP"); diff --git a/ext/bulk_import_export/events.php b/ext/bulk_import_export/events.php index 62244709..e75f8e64 100644 --- a/ext/bulk_import_export/events.php +++ b/ext/bulk_import_export/events.php @@ -7,6 +7,7 @@ class BulkExportEvent extends Event public function __construct(Image $image) { + parent::__construct(); $this->image = $image; } } @@ -19,6 +20,7 @@ class BulkImportEvent extends Event public function __construct(Image $image, $fields) { + parent::__construct(); $this->image = $image; $this->fields = $fields; } diff --git a/ext/bulk_import_export/main.php b/ext/bulk_import_export/main.php index f5f76374..6a4ac039 100644 --- a/ext/bulk_import_export/main.php +++ b/ext/bulk_import_export/main.php @@ -100,7 +100,7 @@ class BulkImportExport extends DataHandlerExtension public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event) { - global $user, $config; + global $user; if ($user->can(Permissions::BULK_EXPORT)) { $event->add_action(self::EXPORT_ACTION_NAME, "Export"); @@ -167,7 +167,6 @@ class BulkImportExport extends DataHandlerExtension private function get_export_data(ZipArchive $zip): ?array { $info = $zip->getStream(self::EXPORT_INFO_FILE_NAME); - $json_data = []; if ($info !== false) { try { $json_string = stream_get_contents($info); diff --git a/ext/download/events.php b/ext/download/events.php index 431cbe37..5a27bfc8 100644 --- a/ext/download/events.php +++ b/ext/download/events.php @@ -9,6 +9,7 @@ class ImageDownloadingEvent extends Event public function __construct(Image $image, String $path, string $mime) { + parent::__construct(); $this->image = $image; $this->path = $path; $this->mime = $mime; diff --git a/ext/media/main.php b/ext/media/main.php index 5a08b649..b9371965 100644 --- a/ext/media/main.php +++ b/ext/media/main.php @@ -230,14 +230,10 @@ class Media extends Extension // } } - const CONTENT_SEARCH_TERM_REGEX = "/^content[=|:]((video)|(audio)|(image)|(unknown))$/i"; - public function onSearchTermParse(SearchTermParseEvent $event) { - global $database; - if (is_null($event->term)) { return; } @@ -323,10 +319,11 @@ class Media extends Extension global $config; $ffmpeg = $config->get_string(MediaConfig::FFMPEG_PATH); - if ($ffmpeg == null || $ffmpeg == "") { - throw new MediaException("ffmpeg command configured"); + if (empty($ffmpeg)) { + throw new MediaException("ffmpeg command not configured"); } + $ok = false; $inname = warehouse_path(Image::IMAGE_DIR, $hash); $tmpname = tempnam(sys_get_temp_dir(), "shimmie_ffmpeg_thumb"); try { @@ -335,18 +332,6 @@ class Media extends Extension $orig_size = self::video_size($inname); $scaled_size = get_thumbnail_size($orig_size[0], $orig_size[1], true); - $codec = "mjpeg"; - $quality = $config->get_int(ImageConfig::THUMB_QUALITY); - if ($config->get_string(ImageConfig::THUMB_MIME) == MimeType::WEBP) { - $codec = "libwebp"; - } else { - // mjpeg quality ranges from 2-31, with 2 being the best quality. - $quality = floor(31 - (31 * ($quality / 100))); - if ($quality < 2) { - $quality = 2; - } - } - $args = [ escapeshellarg($ffmpeg), "-y", "-i", escapeshellarg($inname), @@ -363,18 +348,15 @@ class Media extends Extension if ((int)$ret === (int)0) { log_debug('media', "Generating thumbnail with command `$cmd`, returns $ret"); - create_scaled_image($tmpname, $outname, $scaled_size, MimeType::PNG); - - - return true; + $ok = true; } else { log_error('media', "Generating thumbnail with command `$cmd`, returns $ret"); - return false; } } finally { @unlink($tmpname); } + return $ok; } diff --git a/ext/media/theme.php b/ext/media/theme.php index 6f1fe2b7..724b125b 100644 --- a/ext/media/theme.php +++ b/ext/media/theme.php @@ -1,11 +1,5 @@ get_bool(PrivateImageConfig::USER_VIEW_DEFAULT); $matches = []; @@ -200,7 +200,7 @@ class PrivateImage extends Extension public static function privatize_image($image_id) { - global $database, $user; + global $database; $database->execute( "UPDATE images SET private = :true WHERE id = :id AND private = :false", @@ -220,7 +220,7 @@ class PrivateImage extends Extension public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) { - global $user, $config; + global $user; if ($user->can(Permissions::SET_PRIVATE_IMAGE) && $user->id==$event->image->owner_id) { $event->add_part($this->theme->get_image_admin_html($event->image)); } @@ -236,7 +236,7 @@ class PrivateImage extends Extension public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event) { - global $user, $config; + global $user; if ($user->can(Permissions::SET_PRIVATE_IMAGE)) { $event->add_action("bulk_privatize_image", "Make Private"); diff --git a/ext/private_image/theme.php b/ext/private_image/theme.php index 263503ca..b937c924 100644 --- a/ext/private_image/theme.php +++ b/ext/private_image/theme.php @@ -1,6 +1,4 @@ get_bool(ResizeConfig::GET_ENABLED) && $user->can(Permissions::EDIT_FILES) && $this->can_resize_mime($event->image->get_mime())) { - $new_width = $event->image->width; - $new_height = $event->image->height; - - $max_height = 0; - $max_width = 0; - if (isset($_GET['max_height'])) { $max_height = int_escape($_GET['max_height']); } else { diff --git a/ext/source_history/theme.php b/ext/source_history/theme.php index 649eda76..1b9cac66 100644 --- a/ext/source_history/theme.php +++ b/ext/source_history/theme.php @@ -1,14 +1,8 @@ get_version(TranscodeConfig::VERSION) < 1) { $old_extensions =[]; foreach (array_values(self::INPUT_MIMES) as $mime) { diff --git a/ext/transcode_video/main.php b/ext/transcode_video/main.php index 9cd2a717..8ca820de 100644 --- a/ext/transcode_video/main.php +++ b/ext/transcode_video/main.php @@ -42,7 +42,7 @@ class TranscodeVideo extends Extension public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) { - global $user, $config; + global $user; if ($event->image->video===true && $user->can(Permissions::EDIT_FILES)) { $options = self::get_output_options($event->image->get_mime(), $event->image->video_codec); @@ -54,8 +54,6 @@ class TranscodeVideo extends Extension public function onSetupBuilding(SetupBuildingEvent $event) { - global $config; - $sb = new SetupBlock("Video Transcode"); $sb->start_table(); $sb->add_bool_option(TranscodeVideoConfig::ENABLED, "Allow transcoding images: ", true); @@ -126,10 +124,9 @@ class TranscodeVideo extends Extension } } - public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event) { - global $user, $config; + global $user; if ($user->can(Permissions::EDIT_FILES)) { $event->add_action( diff --git a/ext/upload/main.php b/ext/upload/main.php index 81fe585a..6ffb4cc8 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -32,7 +32,6 @@ class DataUploadEvent extends Event public function __construct(string $tmpname, array $metadata) { parent::__construct(); - global $config; assert(file_exists($tmpname)); assert(is_string($metadata["filename"])); diff --git a/ext/upload/theme.php b/ext/upload/theme.php index 7f7a27ce..73d2d96a 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -227,7 +227,6 @@ class UploadTheme extends Themelet { global $config; - $upload_count = $config->get_int(UploadConfig::COUNT); $accept = $this->get_accept(); $max_size = $config->get_int(UploadConfig::SIZE); diff --git a/ext/user_config/main.php b/ext/user_config/main.php index 119cd257..4a9510e1 100644 --- a/ext/user_config/main.php +++ b/ext/user_config/main.php @@ -1,6 +1,6 @@