Page MenuHomePhorge
Diviner Tech Docs PhabricatorSystemActionEngine

final class PhabricatorSystemActionEngine
Phorge Technical Documentation (System)

This class is not documented.

Methods

public function __get($name)
Inherited

This method is not documented.
Parameters
$name
Return
wild

public function __set($name, $value)
Inherited

This method is not documented.
Parameters
$name
$value
Return
wild

public function current()
Inherited

This method is not documented.
Return
wild

public function key()
Inherited

This method is not documented.
Return
wild

public function next()
Inherited

This method is not documented.
Return
wild

public function rewind()
Inherited

This method is not documented.
Return
wild

public function valid()
Inherited

This method is not documented.
Return
wild

private function throwOnAttemptedIteration()
Inherited

This method is not documented.
Return
wild

public function getPhobjectClassConstant($key, $byte_limit)
Inherited

Phobject

Read the value of a class constant.

This is the same as just typing self::CONSTANTNAME, but throws a more useful message if the constant is not defined and allows the constant to be limited to a maximum length.

Parameters
string$keyName of the constant.
int|null$byte_limitMaximum number of bytes permitted in the value.
Return
stringValue of the constant.

public static function willTakeAction($actors, $action, $score)

Prepare to take an action, throwing an exception if the user has exceeded the rate limit.

The $actors are a list of strings. Normally this will be a list of user PHIDs, but some systems use other identifiers (like email addresses). Each actor's score threshold is tracked independently. If any actor exceeds the rate limit for the action, this method throws.

The $action defines the actual thing being rate limited, and sets the limit.

You can pass either a positive, zero, or negative $score to this method:

  • If the score is positive, the user is given that many points toward the rate limit after the limit is checked. Over time, this will cause them to hit the rate limit and be prevented from taking further actions.
  • If the score is zero, the rate limit is checked but no score changes are made. This allows you to check for a rate limit before beginning a workflow, so the user doesn't fill in a form only to get rate limited at the end.
  • If the score is negative, the user is credited points, allowing them to take more actions than the limit normally permits. By awarding points for failed actions and credits for successful actions, a system can be sensitive to failure without overly restricting legitimate uses.

If any actor is exceeding their rate limit, this method throws a PhabricatorSystemActionRateLimitException.

Parameters
list<string>$actorsList of actors.
PhabricatorSystemAction$actionAction being taken.
float$scoreScore or credit, see above.
Return
void

public static function loadBlockedActors($actors, $action, $score)

This method is not documented.
Parameters
array$actors
PhabricatorSystemAction$action
$score
Return
wild

public static function loadScores($actors, $action)

This method is not documented.
Parameters
array$actors
PhabricatorSystemAction$action
Return
wild

private static function recordAction($actors, $action, $score)

This method is not documented.
Parameters
array$actors
PhabricatorSystemAction$action
$score
Return
wild

private static function getWindow()

This method is not documented.
Return
wild

public static function resetActions($actors)

Reset all action counts for actions taken by some set of actors in the previous action window.

Parameters
list<string>$actorsActors to reset counts for.
Return
intNumber of actions cleared.

public static function newActorFromRequest($request)

This method is not documented.
Parameters
AphrontRequest$request
Return
wild