diff --git a/composer.lock b/composer.lock
index 5fad216b..ff2a0d95 100644
--- a/composer.lock
+++ b/composer.lock
@@ -614,12 +614,12 @@
"source": {
"type": "git",
"url": "https://github.com/shish/gqla.git",
- "reference": "6b30c17214389013314cc3441e0db766fee8119c"
+ "reference": "3b9d2973c0587f10f3b57990585fbdb7588ce54f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/shish/gqla/zipball/6b30c17214389013314cc3441e0db766fee8119c",
- "reference": "6b30c17214389013314cc3441e0db766fee8119c",
+ "url": "https://api.github.com/repos/shish/gqla/zipball/3b9d2973c0587f10f3b57990585fbdb7588ce54f",
+ "reference": "3b9d2973c0587f10f3b57990585fbdb7588ce54f",
"shasum": ""
},
"require": {
@@ -659,7 +659,7 @@
"issues": "https://github.com/shish/gqla/issues",
"source": "https://github.com/shish/gqla/tree/main"
},
- "time": "2023-02-04T12:47:18+00:00"
+ "time": "2023-02-04T20:10:44+00:00"
},
{
"name": "shish/microcrud",
@@ -770,16 +770,16 @@
},
{
"name": "webonyx/graphql-php",
- "version": "v15.0.3",
+ "version": "v15.1.0",
"source": {
"type": "git",
"url": "https://github.com/webonyx/graphql-php.git",
- "reference": "bfa78b44a93c00ebc9a1bc92497bc170a0e3b656"
+ "reference": "c58c08f3e2d6c43a8e0bb4bcc61ecb2a3e4f85df"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/bfa78b44a93c00ebc9a1bc92497bc170a0e3b656",
- "reference": "bfa78b44a93c00ebc9a1bc92497bc170a0e3b656",
+ "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/c58c08f3e2d6c43a8e0bb4bcc61ecb2a3e4f85df",
+ "reference": "c58c08f3e2d6c43a8e0bb4bcc61ecb2a3e4f85df",
"shasum": ""
},
"require": {
@@ -828,7 +828,7 @@
],
"support": {
"issues": "https://github.com/webonyx/graphql-php/issues",
- "source": "https://github.com/webonyx/graphql-php/tree/v15.0.3"
+ "source": "https://github.com/webonyx/graphql-php/tree/v15.1.0"
},
"funding": [
{
@@ -836,7 +836,7 @@
"type": "open_collective"
}
],
- "time": "2023-02-02T21:59:56+00:00"
+ "time": "2023-02-04T15:00:26+00:00"
}
],
"packages-dev": [
@@ -2657,12 +2657,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "8072151d4782529eca00770db6dccbb49ce4cdb1"
+ "reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8072151d4782529eca00770db6dccbb49ce4cdb1",
- "reference": "8072151d4782529eca00770db6dccbb49ce4cdb1",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7b1615e3e887d6c719121c6d4a44b0ab9645555",
+ "reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555",
"shasum": ""
},
"require": {
@@ -2735,7 +2735,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
- "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6"
+ "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.3"
},
"funding": [
{
@@ -2751,7 +2751,7 @@
"type": "tidelift"
}
],
- "time": "2023-02-04T08:53:49+00:00"
+ "time": "2023-02-04T13:37:15+00:00"
},
{
"name": "psr/cache",
diff --git a/core/imageboard/image.php b/core/imageboard/image.php
index faec4c3f..dce56070 100644
--- a/core/imageboard/image.php
+++ b/core/imageboard/image.php
@@ -503,9 +503,7 @@ class Image
#[Field(name: "nice_name")]
public function get_nice_image_name(): string
{
- $plte = new ParseLinkTemplateEvent('$id - $tags.$ext', $this);
- send_event($plte);
- return $plte->text;
+ return send_event(new ParseLinkTemplateEvent('$id - $tags.$ext', $this))->text;
}
/**
@@ -550,9 +548,7 @@ class Image
public function get_tooltip(): string
{
global $config;
- $plte = new ParseLinkTemplateEvent($config->get_string(ImageConfig::TIP), $this);
- send_event($plte);
- return $plte->text;
+ return send_event(new ParseLinkTemplateEvent($config->get_string(ImageConfig::TIP), $this))->text;
}
/**
@@ -563,9 +559,7 @@ class Image
public function get_info(): string
{
global $config;
- $plte = new ParseLinkTemplateEvent($config->get_string(ImageConfig::INFO), $this);
- send_event($plte);
- return $plte->text;
+ return send_event(new ParseLinkTemplateEvent($config->get_string(ImageConfig::INFO), $this))->text;
}
diff --git a/core/imageboard/misc.php b/core/imageboard/misc.php
index f36e63e1..b65938ab 100644
--- a/core/imageboard/misc.php
+++ b/core/imageboard/misc.php
@@ -53,9 +53,7 @@ function add_image(string $tmpname, string $filename, string $tags): int
$metadata['tags'] = Tag::explode($tags);
$metadata['source'] = null;
- $due = new DataUploadEvent($tmpname, $metadata);
- send_event($due);
-
+ $due = send_event(new DataUploadEvent($tmpname, $metadata));
return $due->image_id;
}
diff --git a/core/util.php b/core/util.php
index 894308d2..d3a73552 100644
--- a/core/util.php
+++ b/core/util.php
@@ -207,8 +207,7 @@ function get_session_ip(Config $config): string
*/
function format_text(string $string): string
{
- $event = new TextFormattingEvent($string);
- send_event($event);
+ $event = send_event(new TextFormattingEvent($string));
return $event->formatted;
}
diff --git a/ext/auto_tagger/main.php b/ext/auto_tagger/main.php
index a4abf1d3..370cdac5 100644
--- a/ext/auto_tagger/main.php
+++ b/ext/auto_tagger/main.php
@@ -259,8 +259,7 @@ class AutoTagger extends Extension
foreach ($image_ids as $image_id) {
$image_id = (int) $image_id;
$image = Image::by_id($image_id);
- $event = new TagSetEvent($image, $image->get_tag_array());
- send_event($event);
+ send_event(new TagSetEvent($image, $image->get_tag_array()));
}
}
}
diff --git a/ext/bulk_import_export/main.php b/ext/bulk_import_export/main.php
index 93c5b843..03982ae2 100644
--- a/ext/bulk_import_export/main.php
+++ b/ext/bulk_import_export/main.php
@@ -126,8 +126,7 @@ class BulkImportExport extends DataHandlerExtension
foreach ($event->items as $image) {
$img_loc = warehouse_path(Image::IMAGE_DIR, $image->hash, false);
- $export_event = new BulkExportEvent($image);
- send_event($export_event);
+ $export_event = send_event(new BulkExportEvent($image));
$data = $export_event->fields;
$data["hash"] = $image->hash;
$data["tags"] = $image->get_tag_array();
diff --git a/ext/comment/main.php b/ext/comment/main.php
index 615d3c16..3de9cdc5 100644
--- a/ext/comment/main.php
+++ b/ext/comment/main.php
@@ -221,8 +221,7 @@ class CommentList extends Extension
if (isset($_POST['image_id']) && isset($_POST['comment'])) {
try {
$i_iid = int_escape($_POST['image_id']);
- $cpe = new CommentPostingEvent(int_escape($_POST['image_id']), $user, $_POST['comment']);
- send_event($cpe);
+ send_event(new CommentPostingEvent(int_escape($_POST['image_id']), $user, $_POST['comment']));
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/$i_iid", null, "comment_on_$i_iid"));
} catch (CommentPostingException $ex) {
diff --git a/ext/comment/theme.php b/ext/comment/theme.php
index d212ece0..c7ba9e94 100644
--- a/ext/comment/theme.php
+++ b/ext/comment/theme.php
@@ -198,8 +198,7 @@ class CommentListTheme extends Themelet
{
global $config, $user;
- $tfe = new TextFormattingEvent($comment->comment);
- send_event($tfe);
+ $tfe = send_event(new TextFormattingEvent($comment->comment));
$i_uid = $comment->owner_id;
$h_name = html_escape($comment->owner_name);
diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php
index 36defedf..5e49a03d 100644
--- a/ext/cron_uploader/main.php
+++ b/ext/cron_uploader/main.php
@@ -481,8 +481,7 @@ class CronUploader extends Extension
}
$metadata ['tags'] = $tagArray;
$metadata ['source'] = null;
- $event = new DataUploadEvent($tmpname, $metadata);
- send_event($event);
+ $event = send_event(new DataUploadEvent($tmpname, $metadata));
// Generate info message
if ($event->image_id == -1) {
diff --git a/ext/forum/theme.php b/ext/forum/theme.php
index 302221f7..9e7bab4e 100644
--- a/ext/forum/theme.php
+++ b/ext/forum/theme.php
@@ -106,10 +106,7 @@ class ForumTheme extends Themelet
$current_post++;
$message = $post["message"];
- $tfe = new TextFormattingEvent($message);
- send_event($tfe);
- $message = $tfe->formatted;
-
+ $message = send_event(new TextFormattingEvent($message))->formatted;
$message = str_replace('\n\r', '
', $message);
$message = str_replace('\r\n', '
', $message);
$message = str_replace('\n', '
', $message);
diff --git a/ext/help_pages/main.php b/ext/help_pages/main.php
index 28519599..2a208c46 100644
--- a/ext/help_pages/main.php
+++ b/ext/help_pages/main.php
@@ -44,9 +44,7 @@ class HelpPages extends Extension
private function get_pages(): array
{
if ($this->pages==null) {
- $e = new HelpPageListBuildingEvent();
- send_event($e);
- $this->pages = $e->pages;
+ $this->pages = send_event(new HelpPageListBuildingEvent())->pages;
}
return $this->pages;
}
@@ -74,8 +72,7 @@ class HelpPages extends Extension
$this->theme->display_help_page($title);
- $hpbe = new HelpPageBuildingEvent($name);
- send_event($hpbe);
+ $hpbe = send_event(new HelpPageBuildingEvent($name));
asort($hpbe->blocks);
foreach ($hpbe->blocks as $key=>$value) {
diff --git a/ext/index/main.php b/ext/index/main.php
index 3bb56976..446732e1 100644
--- a/ext/index/main.php
+++ b/ext/index/main.php
@@ -114,8 +114,7 @@ class Index extends Extension
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link('post/view/'.$images[0]->id));
} else {
- $plbe = new PostListBuildingEvent($search_terms);
- send_event($plbe);
+ $plbe = send_event(new PostListBuildingEvent($search_terms));
$this->theme->set_page($page_number, $total_pages, $search_terms);
$this->theme->display_page($page, $images);
diff --git a/ext/index/theme.php b/ext/index/theme.php
index b9984bf8..411a11a2 100644
--- a/ext/index/theme.php
+++ b/ext/index/theme.php
@@ -122,8 +122,7 @@ and of course start organising your images :-)
// only show first line of wiki
$short_wiki_description = explode("\n", $wikiPage->body, 2)[0];
- $tfe = new TextFormattingEvent($short_wiki_description);
- send_event($tfe);
+ $tfe = send_event(new TextFormattingEvent($short_wiki_description));
$short_wiki_description = $tfe->formatted;
}
$wikiLink = make_link("wiki/$st");
diff --git a/ext/notes/main.php b/ext/notes/main.php
index ce3702e0..67df6f02 100644
--- a/ext/notes/main.php
+++ b/ext/notes/main.php
@@ -305,7 +305,7 @@ class Notes extends Extension
];
// validate parameters
- if (array_search(null, $note)|| strlen($note['noteText']) == 0) {
+ if (empty($note['note'])) {
return;
}
diff --git a/ext/ouroboros_api/main.php b/ext/ouroboros_api/main.php
index c2ab19b8..07ec46c2 100644
--- a/ext/ouroboros_api/main.php
+++ b/ext/ouroboros_api/main.php
@@ -171,10 +171,7 @@ class OuroborosPost extends _SafeOuroborosImage
$this->is_note_locked = $post['is_note_locked'];
}
if (array_key_exists('parent_id', $post)) {
- $this->parent_id = filter_var(
- $post['parent_id'],
- FILTER_SANITIZE_NUMBER_INT
- );
+ $this->parent_id = int_escape($post['parent_id']);
}
}
}
@@ -386,8 +383,7 @@ class OuroborosAPI extends Extension
}
$meta['extension'] = pathinfo($meta['filename'], PATHINFO_EXTENSION);
try {
- $upload = new DataUploadEvent($meta['file'], $meta);
- send_event($upload);
+ send_event(new DataUploadEvent($meta['file'], $meta));
$image = Image::by_hash($meta['hash']);
if (!is_null($image)) {
$this->sendResponse(200, make_link('post/view/' . $image->id), true);
diff --git a/ext/pools/main.php b/ext/pools/main.php
index 017d136e..85fff391 100644
--- a/ext/pools/main.php
+++ b/ext/pools/main.php
@@ -236,14 +236,12 @@ class Pools extends Extension
case "create": // ADD _POST
try {
$title = $_POST["title"];
- $event = new PoolCreationEvent(
+ $event = send_event(new PoolCreationEvent(
$title,
$user,
bool_escape($_POST["public"]),
$_POST["description"]
- );
-
- send_event($event);
+ ));
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("pool/view/" . $event->new_id));
} catch (PoolCreationException $e) {
@@ -588,8 +586,7 @@ class Pools extends Extension
return;
}
$new_pool_title = $_POST['bulk_pool_new'];
- $pce = new PoolCreationEvent($new_pool_title);
- send_event($pce);
+ $pce = send_event(new PoolCreationEvent($new_pool_title));
send_event(new PoolAddPostsEvent($pce->new_id, iterator_map_to_array("Shimmie2\_image_to_id", $event->items)));
break;
}
diff --git a/ext/pools/theme.php b/ext/pools/theme.php
index cbdfdd4b..79f8c2ec 100644
--- a/ext/pools/theme.php
+++ b/ext/pools/theme.php
@@ -144,8 +144,7 @@ class PoolsTheme extends Themelet
$this->sidebar_options($page, $pool, $check_all);
}
}
- $tfe = new TextFormattingEvent($pool->description);
- send_event($tfe);
+ $tfe = send_event(new TextFormattingEvent($pool->description));
$page->add_block(new Block(html_escape($pool->title), $tfe->formatted, "main", 10));
}
}
diff --git a/ext/rating/main.php b/ext/rating/main.php
index 0c551412..ba54383a 100644
--- a/ext/rating/main.php
+++ b/ext/rating/main.php
@@ -295,8 +295,7 @@ class Ratings extends Extension
$ratings = array_intersect(str_split($ratings), Ratings::get_user_class_privs($user));
$rating = $ratings[0];
$image = Image::by_id($event->image_id);
- $re = new RatingSetEvent($image, $rating);
- send_event($re);
+ send_event(new RatingSetEvent($image, $rating));
}
}
diff --git a/ext/regen_thumb/main.php b/ext/regen_thumb/main.php
index 9c4119b0..76327f29 100644
--- a/ext/regen_thumb/main.php
+++ b/ext/regen_thumb/main.php
@@ -12,8 +12,7 @@ class RegenThumb extends Extension
public function regenerate_thumbnail(Image $image, bool $force = true): bool
{
global $cache;
- $event = new ThumbnailGenerationEvent($image->hash, $image->get_mime(), $force);
- send_event($event);
+ $event = send_event(new ThumbnailGenerationEvent($image->hash, $image->get_mime(), $force));
$cache->delete("thumb-block:{$image->id}");
return $event->generated;
}
@@ -126,8 +125,7 @@ class RegenThumb extends Extension
continue;
}
}
- $event = new ThumbnailGenerationEvent($image["hash"], $image["mime"], $force);
- send_event($event);
+ $event = send_event(new ThumbnailGenerationEvent($image["hash"], $image["mime"], $force));
if ($event->generated) {
$i++;
}
diff --git a/ext/report_image/theme.php b/ext/report_image/theme.php
index fdfd0324..82dd33c2 100644
--- a/ext/report_image/theme.php
+++ b/ext/report_image/theme.php
@@ -21,8 +21,7 @@ class ReportImageTheme extends Themelet
$reporter_name = html_escape($report['reporter_name']);
$userlink = "$reporter_name";
- $iabbe = new ImageAdminBlockBuildingEvent($image, $user, "report");
- send_event($iabbe);
+ $iabbe = send_event(new ImageAdminBlockBuildingEvent($image, $user, "report"));
ksort($iabbe->parts);
$actions = join("
", $iabbe->parts);
diff --git a/ext/resize/main.php b/ext/resize/main.php
index 1a86b43c..96ca6ec3 100644
--- a/ext/resize/main.php
+++ b/ext/resize/main.php
@@ -192,15 +192,14 @@ class ResizeImage extends Extension
throw new ImageResizeException("Unable to save temporary image file.");
}
- $mre = new MediaResizeEvent(
+ send_event(new MediaResizeEvent(
$config->get_string(ResizeConfig::ENGINE),
$event->path,
$event->mime,
$tmp_filename,
$new_width,
$new_height
- );
- send_event($mre);
+ ));
if ($event->file_modified===true&&$event->path!=$event->image->get_image_filename()) {
// This means that we're dealing with a temp file that will need cleaned up
diff --git a/ext/system/main.php b/ext/system/main.php
index 2cb66073..f33a7a12 100644
--- a/ext/system/main.php
+++ b/ext/system/main.php
@@ -11,8 +11,7 @@ class System extends Extension
global $page;
if ($event->page_matches("system")) {
- $e = new PageSubNavBuildingEvent("system");
- send_event($e);
+ $e = send_event(new PageSubNavBuildingEvent("system"));
usort($e->links, "Shimmie2\sort_nav_links");
$link = $e->links[0]->link;
diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php
index 69010372..51d70a31 100644
--- a/ext/tag_edit/main.php
+++ b/ext/tag_edit/main.php
@@ -74,8 +74,7 @@ class TagSetEvent extends Event
continue;
}
- $ttpe = new TagTermCheckEvent($tag);
- send_event($ttpe);
+ $ttpe = send_event(new TagTermCheckEvent($tag));
//seperate tags from metatags
if (!$ttpe->metatag) {
diff --git a/ext/tagger_xml/main.php b/ext/tagger_xml/main.php
index b736b98d..e945e2eb 100644
--- a/ext/tagger_xml/main.php
+++ b/ext/tagger_xml/main.php
@@ -72,7 +72,7 @@ class TaggerXML extends Extension
$count = ["max"=>$count];
} else {
$q_from = "FROM `tags`";
- $count = null;
+ $count = [];
}
$tags = $database->execute(
@@ -97,33 +97,26 @@ class TaggerXML extends Extension
return $this->list_to_xml($tags, "image", (string)$image_id);
}
- private function list_to_xml(\FFSPHP\PDOStatement $tags, string $type, string $query, ?array$misc=null): string
+ private function list_to_xml(\FFSPHP\PDOStatement $tags, string $type, string $query, ?array $misc=[]): string
{
- // @phpstan-ignore-next-line
- $r = $tags->_numOfRows;
-
- $s_misc = "";
+ $props = [
+ "id"=>$type,
+ "query"=>$query,
+ // @phpstan-ignore-next-line
+ "rows"=>$tags->_numOfRows
+ ];
if (!is_null($misc)) {
foreach ($misc as $attr => $val) {
- $s_misc .= " ".$attr."=\"".$val."\"";
+ $props[$attr] = $val;
}
}
- $result = "";
+ $list = new \MicroHTML\HTMLElement("list", [$props]);
foreach ($tags as $tag) {
- $result .= $this->tag_to_xml($tag);
+ $list->appendChild(new \MicroHTML\HTMLElement("tag", [["id"=>$tag["id"], "count"=>$tag["count"]], $tag["tag"]]));
}
- return $result."
";
- }
- private function tag_to_xml(\PDORow $tag): string
- {
- return
- "