send_event(T) -> T

This commit is contained in:
Shish 2023-02-04 20:50:26 +00:00
parent 8492ae9ea4
commit 689b2b13af
38 changed files with 77 additions and 154 deletions

30
composer.lock generated
View file

@ -614,12 +614,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/shish/gqla.git", "url": "https://github.com/shish/gqla.git",
"reference": "6b30c17214389013314cc3441e0db766fee8119c" "reference": "3b9d2973c0587f10f3b57990585fbdb7588ce54f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/shish/gqla/zipball/6b30c17214389013314cc3441e0db766fee8119c", "url": "https://api.github.com/repos/shish/gqla/zipball/3b9d2973c0587f10f3b57990585fbdb7588ce54f",
"reference": "6b30c17214389013314cc3441e0db766fee8119c", "reference": "3b9d2973c0587f10f3b57990585fbdb7588ce54f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -659,7 +659,7 @@
"issues": "https://github.com/shish/gqla/issues", "issues": "https://github.com/shish/gqla/issues",
"source": "https://github.com/shish/gqla/tree/main" "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", "name": "shish/microcrud",
@ -770,16 +770,16 @@
}, },
{ {
"name": "webonyx/graphql-php", "name": "webonyx/graphql-php",
"version": "v15.0.3", "version": "v15.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/webonyx/graphql-php.git", "url": "https://github.com/webonyx/graphql-php.git",
"reference": "bfa78b44a93c00ebc9a1bc92497bc170a0e3b656" "reference": "c58c08f3e2d6c43a8e0bb4bcc61ecb2a3e4f85df"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/webonyx/graphql-php/zipball/bfa78b44a93c00ebc9a1bc92497bc170a0e3b656", "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/c58c08f3e2d6c43a8e0bb4bcc61ecb2a3e4f85df",
"reference": "bfa78b44a93c00ebc9a1bc92497bc170a0e3b656", "reference": "c58c08f3e2d6c43a8e0bb4bcc61ecb2a3e4f85df",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -828,7 +828,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/webonyx/graphql-php/issues", "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": [ "funding": [
{ {
@ -836,7 +836,7 @@
"type": "open_collective" "type": "open_collective"
} }
], ],
"time": "2023-02-02T21:59:56+00:00" "time": "2023-02-04T15:00:26+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
@ -2657,12 +2657,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "8072151d4782529eca00770db6dccbb49ce4cdb1" "reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8072151d4782529eca00770db6dccbb49ce4cdb1", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7b1615e3e887d6c719121c6d4a44b0ab9645555",
"reference": "8072151d4782529eca00770db6dccbb49ce4cdb1", "reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2735,7 +2735,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues", "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": [ "funding": [
{ {
@ -2751,7 +2751,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-02-04T08:53:49+00:00" "time": "2023-02-04T13:37:15+00:00"
}, },
{ {
"name": "psr/cache", "name": "psr/cache",

View file

@ -503,9 +503,7 @@ class Image
#[Field(name: "nice_name")] #[Field(name: "nice_name")]
public function get_nice_image_name(): string public function get_nice_image_name(): string
{ {
$plte = new ParseLinkTemplateEvent('$id - $tags.$ext', $this); return send_event(new ParseLinkTemplateEvent('$id - $tags.$ext', $this))->text;
send_event($plte);
return $plte->text;
} }
/** /**
@ -550,9 +548,7 @@ class Image
public function get_tooltip(): string public function get_tooltip(): string
{ {
global $config; global $config;
$plte = new ParseLinkTemplateEvent($config->get_string(ImageConfig::TIP), $this); return send_event(new ParseLinkTemplateEvent($config->get_string(ImageConfig::TIP), $this))->text;
send_event($plte);
return $plte->text;
} }
/** /**
@ -563,9 +559,7 @@ class Image
public function get_info(): string public function get_info(): string
{ {
global $config; global $config;
$plte = new ParseLinkTemplateEvent($config->get_string(ImageConfig::INFO), $this); return send_event(new ParseLinkTemplateEvent($config->get_string(ImageConfig::INFO), $this))->text;
send_event($plte);
return $plte->text;
} }

View file

@ -53,9 +53,7 @@ function add_image(string $tmpname, string $filename, string $tags): int
$metadata['tags'] = Tag::explode($tags); $metadata['tags'] = Tag::explode($tags);
$metadata['source'] = null; $metadata['source'] = null;
$due = new DataUploadEvent($tmpname, $metadata); $due = send_event(new DataUploadEvent($tmpname, $metadata));
send_event($due);
return $due->image_id; return $due->image_id;
} }

View file

@ -207,8 +207,7 @@ function get_session_ip(Config $config): string
*/ */
function format_text(string $string): string function format_text(string $string): string
{ {
$event = new TextFormattingEvent($string); $event = send_event(new TextFormattingEvent($string));
send_event($event);
return $event->formatted; return $event->formatted;
} }

View file

@ -259,8 +259,7 @@ class AutoTagger extends Extension
foreach ($image_ids as $image_id) { foreach ($image_ids as $image_id) {
$image_id = (int) $image_id; $image_id = (int) $image_id;
$image = Image::by_id($image_id); $image = Image::by_id($image_id);
$event = new TagSetEvent($image, $image->get_tag_array()); send_event(new TagSetEvent($image, $image->get_tag_array()));
send_event($event);
} }
} }
} }

View file

@ -126,8 +126,7 @@ class BulkImportExport extends DataHandlerExtension
foreach ($event->items as $image) { foreach ($event->items as $image) {
$img_loc = warehouse_path(Image::IMAGE_DIR, $image->hash, false); $img_loc = warehouse_path(Image::IMAGE_DIR, $image->hash, false);
$export_event = new BulkExportEvent($image); $export_event = send_event(new BulkExportEvent($image));
send_event($export_event);
$data = $export_event->fields; $data = $export_event->fields;
$data["hash"] = $image->hash; $data["hash"] = $image->hash;
$data["tags"] = $image->get_tag_array(); $data["tags"] = $image->get_tag_array();

View file

@ -221,8 +221,7 @@ class CommentList extends Extension
if (isset($_POST['image_id']) && isset($_POST['comment'])) { if (isset($_POST['image_id']) && isset($_POST['comment'])) {
try { try {
$i_iid = int_escape($_POST['image_id']); $i_iid = int_escape($_POST['image_id']);
$cpe = new CommentPostingEvent(int_escape($_POST['image_id']), $user, $_POST['comment']); send_event(new CommentPostingEvent(int_escape($_POST['image_id']), $user, $_POST['comment']));
send_event($cpe);
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/$i_iid", null, "comment_on_$i_iid")); $page->set_redirect(make_link("post/view/$i_iid", null, "comment_on_$i_iid"));
} catch (CommentPostingException $ex) { } catch (CommentPostingException $ex) {

View file

@ -198,8 +198,7 @@ class CommentListTheme extends Themelet
{ {
global $config, $user; global $config, $user;
$tfe = new TextFormattingEvent($comment->comment); $tfe = send_event(new TextFormattingEvent($comment->comment));
send_event($tfe);
$i_uid = $comment->owner_id; $i_uid = $comment->owner_id;
$h_name = html_escape($comment->owner_name); $h_name = html_escape($comment->owner_name);

View file

@ -481,8 +481,7 @@ class CronUploader extends Extension
} }
$metadata ['tags'] = $tagArray; $metadata ['tags'] = $tagArray;
$metadata ['source'] = null; $metadata ['source'] = null;
$event = new DataUploadEvent($tmpname, $metadata); $event = send_event(new DataUploadEvent($tmpname, $metadata));
send_event($event);
// Generate info message // Generate info message
if ($event->image_id == -1) { if ($event->image_id == -1) {

View file

@ -106,10 +106,7 @@ class ForumTheme extends Themelet
$current_post++; $current_post++;
$message = $post["message"]; $message = $post["message"];
$tfe = new TextFormattingEvent($message); $message = send_event(new TextFormattingEvent($message))->formatted;
send_event($tfe);
$message = $tfe->formatted;
$message = str_replace('\n\r', '<br>', $message); $message = str_replace('\n\r', '<br>', $message);
$message = str_replace('\r\n', '<br>', $message); $message = str_replace('\r\n', '<br>', $message);
$message = str_replace('\n', '<br>', $message); $message = str_replace('\n', '<br>', $message);

View file

@ -44,9 +44,7 @@ class HelpPages extends Extension
private function get_pages(): array private function get_pages(): array
{ {
if ($this->pages==null) { if ($this->pages==null) {
$e = new HelpPageListBuildingEvent(); $this->pages = send_event(new HelpPageListBuildingEvent())->pages;
send_event($e);
$this->pages = $e->pages;
} }
return $this->pages; return $this->pages;
} }
@ -74,8 +72,7 @@ class HelpPages extends Extension
$this->theme->display_help_page($title); $this->theme->display_help_page($title);
$hpbe = new HelpPageBuildingEvent($name); $hpbe = send_event(new HelpPageBuildingEvent($name));
send_event($hpbe);
asort($hpbe->blocks); asort($hpbe->blocks);
foreach ($hpbe->blocks as $key=>$value) { foreach ($hpbe->blocks as $key=>$value) {

View file

@ -114,8 +114,7 @@ class Index extends Extension
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link('post/view/'.$images[0]->id)); $page->set_redirect(make_link('post/view/'.$images[0]->id));
} else { } else {
$plbe = new PostListBuildingEvent($search_terms); $plbe = send_event(new PostListBuildingEvent($search_terms));
send_event($plbe);
$this->theme->set_page($page_number, $total_pages, $search_terms); $this->theme->set_page($page_number, $total_pages, $search_terms);
$this->theme->display_page($page, $images); $this->theme->display_page($page, $images);

View file

@ -122,8 +122,7 @@ and of course start organising your images :-)
// only show first line of wiki // only show first line of wiki
$short_wiki_description = explode("\n", $wikiPage->body, 2)[0]; $short_wiki_description = explode("\n", $wikiPage->body, 2)[0];
$tfe = new TextFormattingEvent($short_wiki_description); $tfe = send_event(new TextFormattingEvent($short_wiki_description));
send_event($tfe);
$short_wiki_description = $tfe->formatted; $short_wiki_description = $tfe->formatted;
} }
$wikiLink = make_link("wiki/$st"); $wikiLink = make_link("wiki/$st");

View file

@ -305,7 +305,7 @@ class Notes extends Extension
]; ];
// validate parameters // validate parameters
if (array_search(null, $note)|| strlen($note['noteText']) == 0) { if (empty($note['note'])) {
return; return;
} }

View file

@ -171,10 +171,7 @@ class OuroborosPost extends _SafeOuroborosImage
$this->is_note_locked = $post['is_note_locked']; $this->is_note_locked = $post['is_note_locked'];
} }
if (array_key_exists('parent_id', $post)) { if (array_key_exists('parent_id', $post)) {
$this->parent_id = filter_var( $this->parent_id = int_escape($post['parent_id']);
$post['parent_id'],
FILTER_SANITIZE_NUMBER_INT
);
} }
} }
} }
@ -386,8 +383,7 @@ class OuroborosAPI extends Extension
} }
$meta['extension'] = pathinfo($meta['filename'], PATHINFO_EXTENSION); $meta['extension'] = pathinfo($meta['filename'], PATHINFO_EXTENSION);
try { try {
$upload = new DataUploadEvent($meta['file'], $meta); send_event(new DataUploadEvent($meta['file'], $meta));
send_event($upload);
$image = Image::by_hash($meta['hash']); $image = Image::by_hash($meta['hash']);
if (!is_null($image)) { if (!is_null($image)) {
$this->sendResponse(200, make_link('post/view/' . $image->id), true); $this->sendResponse(200, make_link('post/view/' . $image->id), true);

View file

@ -236,14 +236,12 @@ class Pools extends Extension
case "create": // ADD _POST case "create": // ADD _POST
try { try {
$title = $_POST["title"]; $title = $_POST["title"];
$event = new PoolCreationEvent( $event = send_event(new PoolCreationEvent(
$title, $title,
$user, $user,
bool_escape($_POST["public"]), bool_escape($_POST["public"]),
$_POST["description"] $_POST["description"]
); ));
send_event($event);
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("pool/view/" . $event->new_id)); $page->set_redirect(make_link("pool/view/" . $event->new_id));
} catch (PoolCreationException $e) { } catch (PoolCreationException $e) {
@ -588,8 +586,7 @@ class Pools extends Extension
return; return;
} }
$new_pool_title = $_POST['bulk_pool_new']; $new_pool_title = $_POST['bulk_pool_new'];
$pce = new PoolCreationEvent($new_pool_title); $pce = send_event(new PoolCreationEvent($new_pool_title));
send_event($pce);
send_event(new PoolAddPostsEvent($pce->new_id, iterator_map_to_array("Shimmie2\_image_to_id", $event->items))); send_event(new PoolAddPostsEvent($pce->new_id, iterator_map_to_array("Shimmie2\_image_to_id", $event->items)));
break; break;
} }

View file

@ -144,8 +144,7 @@ class PoolsTheme extends Themelet
$this->sidebar_options($page, $pool, $check_all); $this->sidebar_options($page, $pool, $check_all);
} }
} }
$tfe = new TextFormattingEvent($pool->description); $tfe = send_event(new TextFormattingEvent($pool->description));
send_event($tfe);
$page->add_block(new Block(html_escape($pool->title), $tfe->formatted, "main", 10)); $page->add_block(new Block(html_escape($pool->title), $tfe->formatted, "main", 10));
} }
} }

View file

@ -295,8 +295,7 @@ class Ratings extends Extension
$ratings = array_intersect(str_split($ratings), Ratings::get_user_class_privs($user)); $ratings = array_intersect(str_split($ratings), Ratings::get_user_class_privs($user));
$rating = $ratings[0]; $rating = $ratings[0];
$image = Image::by_id($event->image_id); $image = Image::by_id($event->image_id);
$re = new RatingSetEvent($image, $rating); send_event(new RatingSetEvent($image, $rating));
send_event($re);
} }
} }

View file

@ -12,8 +12,7 @@ class RegenThumb extends Extension
public function regenerate_thumbnail(Image $image, bool $force = true): bool public function regenerate_thumbnail(Image $image, bool $force = true): bool
{ {
global $cache; global $cache;
$event = new ThumbnailGenerationEvent($image->hash, $image->get_mime(), $force); $event = send_event(new ThumbnailGenerationEvent($image->hash, $image->get_mime(), $force));
send_event($event);
$cache->delete("thumb-block:{$image->id}"); $cache->delete("thumb-block:{$image->id}");
return $event->generated; return $event->generated;
} }
@ -126,8 +125,7 @@ class RegenThumb extends Extension
continue; continue;
} }
} }
$event = new ThumbnailGenerationEvent($image["hash"], $image["mime"], $force); $event = send_event(new ThumbnailGenerationEvent($image["hash"], $image["mime"], $force));
send_event($event);
if ($event->generated) { if ($event->generated) {
$i++; $i++;
} }

View file

@ -21,8 +21,7 @@ class ReportImageTheme extends Themelet
$reporter_name = html_escape($report['reporter_name']); $reporter_name = html_escape($report['reporter_name']);
$userlink = "<a href='".make_link("user/$reporter_name")."'>$reporter_name</a>"; $userlink = "<a href='".make_link("user/$reporter_name")."'>$reporter_name</a>";
$iabbe = new ImageAdminBlockBuildingEvent($image, $user, "report"); $iabbe = send_event(new ImageAdminBlockBuildingEvent($image, $user, "report"));
send_event($iabbe);
ksort($iabbe->parts); ksort($iabbe->parts);
$actions = join("<br>", $iabbe->parts); $actions = join("<br>", $iabbe->parts);

View file

@ -192,15 +192,14 @@ class ResizeImage extends Extension
throw new ImageResizeException("Unable to save temporary image file."); throw new ImageResizeException("Unable to save temporary image file.");
} }
$mre = new MediaResizeEvent( send_event(new MediaResizeEvent(
$config->get_string(ResizeConfig::ENGINE), $config->get_string(ResizeConfig::ENGINE),
$event->path, $event->path,
$event->mime, $event->mime,
$tmp_filename, $tmp_filename,
$new_width, $new_width,
$new_height $new_height
); ));
send_event($mre);
if ($event->file_modified===true&&$event->path!=$event->image->get_image_filename()) { 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 // This means that we're dealing with a temp file that will need cleaned up

View file

@ -11,8 +11,7 @@ class System extends Extension
global $page; global $page;
if ($event->page_matches("system")) { if ($event->page_matches("system")) {
$e = new PageSubNavBuildingEvent("system"); $e = send_event(new PageSubNavBuildingEvent("system"));
send_event($e);
usort($e->links, "Shimmie2\sort_nav_links"); usort($e->links, "Shimmie2\sort_nav_links");
$link = $e->links[0]->link; $link = $e->links[0]->link;

View file

@ -74,8 +74,7 @@ class TagSetEvent extends Event
continue; continue;
} }
$ttpe = new TagTermCheckEvent($tag); $ttpe = send_event(new TagTermCheckEvent($tag));
send_event($ttpe);
//seperate tags from metatags //seperate tags from metatags
if (!$ttpe->metatag) { if (!$ttpe->metatag) {

View file

@ -72,7 +72,7 @@ class TaggerXML extends Extension
$count = ["max"=>$count]; $count = ["max"=>$count];
} else { } else {
$q_from = "FROM `tags`"; $q_from = "FROM `tags`";
$count = null; $count = [];
} }
$tags = $database->execute( $tags = $database->execute(
@ -97,33 +97,26 @@ class TaggerXML extends Extension
return $this->list_to_xml($tags, "image", (string)$image_id); 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 $props = [
$r = $tags->_numOfRows; "id"=>$type,
"query"=>$query,
$s_misc = ""; // @phpstan-ignore-next-line
"rows"=>$tags->_numOfRows
];
if (!is_null($misc)) { if (!is_null($misc)) {
foreach ($misc as $attr => $val) { foreach ($misc as $attr => $val) {
$s_misc .= " ".$attr."=\"".$val."\""; $props[$attr] = $val;
} }
} }
$result = "<list id=\"$type\" query=\"$query\" rows=\"$r\"{$s_misc}>"; $list = new \MicroHTML\HTMLElement("list", [$props]);
foreach ($tags as $tag) { 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."</list>";
}
private function tag_to_xml(\PDORow $tag): string return (string)($list);
{
return
"<tag ".
"id=\"".$tag['id']."\" ".
"count=\"".$tag['count']."\">".
html_escape($tag['tag']).
"</tag>";
} }
private function count(string $query, $values) private function count(string $query, $values)

View file

@ -116,8 +116,7 @@ class UserPage extends Extension
} elseif ($event->get_arg(0) == "create") { } elseif ($event->get_arg(0) == "create") {
$this->page_create(); $this->page_create();
} elseif ($event->get_arg(0) == "create_other") { } elseif ($event->get_arg(0) == "create_other") {
$uce = new UserCreationEvent($_POST['name'], $_POST['pass1'], $_POST['email'], false); send_event(new UserCreationEvent($_POST['name'], $_POST['pass1'], $_POST['email'], false));
send_event($uce);
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("admin")); $page->set_redirect(make_link("admin"));
$page->flash("Created new user"); $page->flash("Created new user");
@ -180,8 +179,7 @@ class UserPage extends Extension
"You aren't logged in. First do that, then you can see your stats." "You aren't logged in. First do that, then you can see your stats."
); );
} elseif (!is_null($display_user) && ($display_user->id != $config->get_int("anon_id"))) { } elseif (!is_null($display_user) && ($display_user->id != $config->get_int("anon_id"))) {
$e = new UserPageBuildingEvent($display_user); $e = send_event(new UserPageBuildingEvent($display_user));
send_event($e);
$this->display_stats($e); $this->display_stats($e);
} else { } else {
$this->theme->display_error( $this->theme->display_error(
@ -248,15 +246,13 @@ class UserPage extends Extension
if ($user->id == $event->display_user->id || $user->can("edit_user_info")) { if ($user->id == $event->display_user->id || $user->can("edit_user_info")) {
$user_config = UserConfig::get_for_user($event->display_user->id); $user_config = UserConfig::get_for_user($event->display_user->id);
$uobe = new UserOperationsBuildingEvent($event->display_user, $user_config); $uobe = send_event(new UserOperationsBuildingEvent($event->display_user, $user_config));
send_event($uobe);
$page->add_block(new Block("Operations", $this->theme->build_operations($event->display_user, $uobe), "main", 60)); $page->add_block(new Block("Operations", $this->theme->build_operations($event->display_user, $uobe), "main", 60));
} }
} }
if ($user->id == $event->display_user->id) { if ($user->id == $event->display_user->id) {
$ubbe = new UserBlockBuildingEvent(); $ubbe = send_event(new UserBlockBuildingEvent());
send_event($ubbe);
ksort($ubbe->parts); ksort($ubbe->parts);
$this->theme->display_user_links($page, $user, $ubbe->parts); $this->theme->display_user_links($page, $user, $ubbe->parts);
} }
@ -423,8 +419,7 @@ class UserPage extends Extension
if ($user->is_anonymous()) { if ($user->is_anonymous()) {
$this->theme->display_login_block($page); $this->theme->display_login_block($page);
} else { } else {
$ubbe = new UserBlockBuildingEvent(); $ubbe = send_event(new UserBlockBuildingEvent());
send_event($ubbe);
ksort($ubbe->parts); ksort($ubbe->parts);
$this->theme->display_user_block($page, $user, $ubbe->parts); $this->theme->display_user_block($page, $user, $ubbe->parts);
} }
@ -508,8 +503,7 @@ class UserPage extends Extension
throw new UserCreationException("Error in captcha"); throw new UserCreationException("Error in captcha");
} }
$uce = new UserCreationEvent($_POST['name'], $_POST['pass1'], $_POST['email'], true); $uce = send_event(new UserCreationEvent($_POST['name'], $_POST['pass1'], $_POST['email'], true));
send_event($uce);
$this->set_login_cookie($uce->username); $this->set_login_cookie($uce->username);
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("user")); $page->set_redirect(make_link("user"));

View file

@ -67,8 +67,7 @@ class UserPageTheme extends Themelet
$tac = $config->get_string("login_tac", ""); $tac = $config->get_string("login_tac", "");
if ($config->get_bool("login_tac_bbcode")) { if ($config->get_bool("login_tac_bbcode")) {
$tfe = new TextFormattingEvent($tac); $tfe = send_event(new TextFormattingEvent($tac));
send_event($tfe);
$tac = $tfe->formatted; $tac = $tfe->formatted;
} }

View file

@ -138,16 +138,7 @@ class UserConfig extends Extension
$this->theme->display_permission_denied(); $this->theme->display_permission_denied();
} else { } else {
if ($event->count_args() == 0) { if ($event->count_args() == 0) {
$display_user = ($event->count_args() == 0) ? $user : User::by_name($event->get_arg(0)); $uobe = send_event(new UserOptionsBuildingEvent($user, new SetupPanel($user_config)));
if ($user->id!=$display_user->id && !$user->can(Permissions::CHANGE_OTHER_USER_SETTING)) {
$this->theme->display_permission_denied();
return;
}
$uobe = new UserOptionsBuildingEvent($display_user, new SetupPanel($user_config));
send_event($uobe);
$this->theme->display_user_config_page($page, $uobe->user, $uobe->panel); $this->theme->display_user_config_page($page, $uobe->user, $uobe->panel);
} elseif ($event->get_arg(0) == "save" && $user->check_auth_token()) { } elseif ($event->get_arg(0) == "save" && $user->check_auth_token()) {
$input = validate_input([ $input = validate_input([

View file

@ -37,8 +37,6 @@ class VarnishPurger extends Extension
throw new SCoreException('PURGE ' . $url . ' unsuccessful (HTTP '. $httpCode . ')'); throw new SCoreException('PURGE ' . $url . ' unsuccessful (HTTP '. $httpCode . ')');
} }
curl_close($ch); curl_close($ch);
assert(!is_null($result) && !is_null($httpCode));
//return $result;
} }
public function onCommentPosting(CommentPostingEvent $event) public function onCommentPosting(CommentPostingEvent $event)

View file

@ -101,13 +101,11 @@ class ViewImage extends Extension
$this->theme->display_meta_headers($image); $this->theme->display_meta_headers($image);
$iibbe = new ImageInfoBoxBuildingEvent($image, $user); $iibbe = send_event(new ImageInfoBoxBuildingEvent($image, $user));
send_event($iibbe);
ksort($iibbe->parts); ksort($iibbe->parts);
$this->theme->display_page($image, $iibbe->parts); $this->theme->display_page($image, $iibbe->parts);
$iabbe = new ImageAdminBlockBuildingEvent($image, $user, "view"); $iabbe = send_event(new ImageAdminBlockBuildingEvent($image, $user, "view"));
send_event($iabbe);
ksort($iabbe->parts); ksort($iabbe->parts);
$this->theme->display_admin_block($page, $iabbe->parts); $this->theme->display_admin_block($page, $iabbe->parts);
} }

View file

@ -21,8 +21,7 @@ class WikiTheme extends Themelet
$nav_page->body = ""; $nav_page->body = "";
} }
$tfe = new TextFormattingEvent($nav_page->body); $tfe = send_event(new TextFormattingEvent($nav_page->body));
send_event($tfe);
// only the admin can edit the sidebar // only the admin can edit the sidebar
if ($user->can(Permissions::WIKI_ADMIN)) { if ($user->can(Permissions::WIKI_ADMIN)) {

View file

@ -247,13 +247,12 @@ abstract class ShimmiePHPUnitTestCase extends TestCase
// post things // post things
protected function post_image(string $filename, string $tags): int protected function post_image(string $filename, string $tags): int
{ {
$dae = new DataUploadEvent($filename, [ $dae = send_event(new DataUploadEvent($filename, [
"filename" => $filename, "filename" => $filename,
"extension" => pathinfo($filename, PATHINFO_EXTENSION), "extension" => pathinfo($filename, PATHINFO_EXTENSION),
"tags" => Tag::explode($tags), "tags" => Tag::explode($tags),
"source" => null, "source" => null,
]); ]));
send_event($dae);
// if($dae->image_id == -1) throw new \Exception("Upload failed :("); // if($dae->image_id == -1) throw new \Exception("Upload failed :(");
return $dae->image_id; return $dae->image_id;
} }
@ -262,8 +261,7 @@ abstract class ShimmiePHPUnitTestCase extends TestCase
{ {
$img = Image::by_id($image_id); $img = Image::by_id($image_id);
if ($img) { if ($img) {
$ide = new ImageDeletionEvent($img, true); send_event(new ImageDeletionEvent($img, true));
send_event($ide);
} }
} }
} }

View file

@ -6,5 +6,4 @@ parameters:
- ../tests - ../tests
- ../themes/default - ../themes/default
ignoreErrors: ignoreErrors:
- '#Attribute class GQLA\\#'
- '#Access to an undefined property Shimmie2\\Image::\$#' - '#Access to an undefined property Shimmie2\\Image::\$#'

View file

@ -95,8 +95,7 @@ class CustomCommentListTheme extends CommentListTheme
{ {
global $user; global $user;
$tfe = new TextFormattingEvent($comment->comment); $tfe = send_event(new TextFormattingEvent($comment->comment));
send_event($tfe);
//$i_uid = $comment->owner_id; //$i_uid = $comment->owner_id;
$h_name = html_escape($comment->owner_name); $h_name = html_escape($comment->owner_name);

View file

@ -62,9 +62,7 @@ class CustomUserPageTheme extends UserPageTheme
global $config; global $config;
$tac = $config->get_string("login_tac", ""); $tac = $config->get_string("login_tac", "");
$tfe = new TextFormattingEvent($tac); $tac = send_event(new TextFormattingEvent($tac))->formatted;
send_event($tfe);
$tac = $tfe->formatted;
$reca = "<tr><td colspan='2'>".captcha_get_html()."</td></tr>"; $reca = "<tr><td colspan='2'>".captcha_get_html()."</td></tr>";

View file

@ -96,8 +96,7 @@ class CustomCommentListTheme extends CommentListTheme
{ {
global $user; global $user;
$tfe = new TextFormattingEvent($comment->comment); $tfe = send_event(new TextFormattingEvent($comment->comment));
send_event($tfe);
//$i_uid = $comment->owner_id; //$i_uid = $comment->owner_id;
$h_name = html_escape($comment->owner_name); $h_name = html_escape($comment->owner_name);

View file

@ -62,9 +62,7 @@ class CustomUserPageTheme extends UserPageTheme
global $config; global $config;
$tac = $config->get_string("login_tac", ""); $tac = $config->get_string("login_tac", "");
$tfe = new TextFormattingEvent($tac); $tac = send_event(new TextFormattingEvent($tac))->formatted;
send_event($tfe);
$tac = $tfe->formatted;
$reca = "<tr><td colspan='2'>".captcha_get_html()."</td></tr>"; $reca = "<tr><td colspan='2'>".captcha_get_html()."</td></tr>";

View file

@ -69,8 +69,7 @@ class CustomCommentListTheme extends CommentListTheme
$inner_id = $this->inner_id; // because custom themes can't add params, because PHP $inner_id = $this->inner_id; // because custom themes can't add params, because PHP
global $user; global $user;
$tfe = new TextFormattingEvent($comment->comment); $tfe = send_event(new TextFormattingEvent($comment->comment));
send_event($tfe);
//$i_uid = $comment->owner_id; //$i_uid = $comment->owner_id;
$h_name = html_escape($comment->owner_name); $h_name = html_escape($comment->owner_name);

View file

@ -64,9 +64,7 @@ class CustomUserPageTheme extends UserPageTheme
$tac = $config->get_string("login_tac", ""); $tac = $config->get_string("login_tac", "");
if ($config->get_bool("login_tac_bbcode")) { if ($config->get_bool("login_tac_bbcode")) {
$tfe = new TextFormattingEvent($tac); $tac = send_event(new TextFormattingEvent($tac))->formatted;
send_event($tfe);
$tac = $tfe->formatted;
} }
$form = SHM_SIMPLE_FORM( $form = SHM_SIMPLE_FORM(