Updated \TamerLib > tm > addFunction() to validate the function name and check if the function name is reserved
This commit is contained in:
parent
21d0075ed5
commit
129c01b96f
1 changed files with 10 additions and 1 deletions
|
@ -293,7 +293,6 @@
|
|||
self::$supervisor->spawnWorker($path, $count, $channel);
|
||||
}
|
||||
|
||||
var_dump('monitoring');
|
||||
self::monitor(-1);
|
||||
}
|
||||
|
||||
|
@ -586,6 +585,16 @@
|
|||
throw new RuntimeException(sprintf('Attempting to addFunction() in \'%s\' mode, only workers can preform addFunction().', self::$mode));
|
||||
}
|
||||
|
||||
if (!preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $function))
|
||||
{
|
||||
throw new InvalidArgumentException("Invalid function name: $function");
|
||||
}
|
||||
|
||||
if(method_exists(__CLASS__, $function))
|
||||
{
|
||||
throw new InvalidArgumentException(sprintf('Attempting to addFunction() with a function name of \'%s\', this is a reserved function name.', $function));
|
||||
}
|
||||
|
||||
self::$function_pointers[$function] = $callback;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue