mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
plugin sticky promotion do not change torrent original field
This commit is contained in:
+10
-1
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user