plugin sticky promotion do not change torrent original field

This commit is contained in:
xiaomlove
2022-06-10 01:25:13 +08:00
parent d95979b579
commit 35f78b4b77
7 changed files with 35 additions and 14 deletions
+10 -1
View File
@@ -6,6 +6,8 @@ class Hook
{
private static array $callbacks = [];
private bool $isDoingAction = false;
public function addFilter($name, $function, $priority, $argc)
{
$id = $this->buildUniqueId($function);
@@ -43,12 +45,18 @@ class Hook
reset(self::$callbacks[$name]);
do_log("name: $name, argc: " . (func_num_args() - 1));
do {
foreach ((array)current(self::$callbacks[$name]) as $callback) {
foreach ((array)current(self::$callbacks[$name]) as $id => $callback) {
$args[1] = $value;
// do_log("name: $name, id: $id, before, params: " . json_encode(array_slice($args, 1, $callback['argc'])));
$value = call_user_func_array($callback['function'], array_slice($args, 1, $callback['argc']));
if ($this->isDoingAction) {
$value = $args[1];
}
// do_log("name: $name, id: $id, after, value: " . var_export($value, true));
}
}
while (next(self::$callbacks[$name]) !== false);
$this->isDoingAction = false;
return $value;
}
@@ -59,6 +67,7 @@ class Hook
public function doAction($name, ...$args)
{
$this->isDoingAction = true;
$this->applyFilter(...func_get_args());
}