From 84b8597dde9792de1df51299c0fdd63a4bca536c Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Fri, 4 Aug 2023 01:30:12 -0400 Subject: [PATCH] Fix issue in displaying mod pages (demote/promote and ban+delete), need to test others --- mod.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mod.php b/mod.php index a7d4f449..a79ffb94 100644 --- a/mod.php +++ b/mod.php @@ -198,7 +198,12 @@ foreach ($pages as $uri => $handler) { } elseif (is_callable("mod_page_$handler")) { call_user_func_array("mod_page_$handler", $matches); } elseif (is_callable("mod_$handler")) { - call_user_func_array("mod_$handler", array_slice($matches, 0, 2)); + // HACK to fix too many params being passed to the function + $reflection = new ReflectionFunction("mod_$handler"); + $arity = $reflection->getNumberOfParameters(); + + // remember that this calls a function by the name of "mod_$handler" with the arguments in $matches, we need to trim those down here or we get an error + call_user_func_array("mod_$handler", array_slice($matches, 0, $arity)); } else { error("Mod page '$handler' not found!"); }