<commit_before><?php
// (c) Copyright 2002-2013 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

class Tiki_Event_Customizer_Executor implements Tiki_Event_EdgeProvider
{
	private $ruleSet;
	private $runner;

	function __construct(Tiki_Event_Customizer_RuleSet $ruleSet, Math_Formula_Runner $runner)
	{
		$this->ruleSet = $ruleSet;
		$this->runner = $runner;
	}

	function __invoke($arguments, $eventName, $priority)
	{
		$rules = $this->ruleSet->getRules();
		$runner = $this->runner;

		$runner->setVariables(array(
			'args' => $arguments,
			'event' => $eventName,
			'priority' => $priority,
		));

		foreach ($rules as $rule) {
			$runner->setFormula($rule);
			$runner->evaluate();
		}
	}

	function getTargetEvents()
	{
		$out = array();

		foreach ($this->ruleSet->getRules() as $rule) {
			$out = array_merge($out, $this->findTrigger($rule));
		}

		return $out;
	}

	private function findTrigger($element)
	{
		if ($element->getType() == 'event-trigger') {<commit_msg>[ENH] Silently fail when a formula fails executing while processing events, as event handlers should not fail<commit_after><?php
// (c) Copyright 2002-2013 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

class Tiki_Event_Customizer_Executor implements Tiki_Event_EdgeProvider
{
	private $ruleSet;
	private $runner;

	function __construct(Tiki_Event_Customizer_RuleSet $ruleSet, Math_Formula_Runner $runner)
	{
		$this->ruleSet = $ruleSet;
		$this->runner = $runner;
	}

	function __invoke($arguments, $eventName, $priority)
	{
		$rules = $this->ruleSet->getRules();
		$runner = $this->runner;

		$runner->setVariables(array(
			'args' => $arguments,
			'event' => $eventName,
			'priority' => $priority,
		));

		foreach ($rules as $rule) {
			try {
				$runner->setFormula($rule);
				$runner->evaluate();
			} catch (Math_Formula_Exception $e) {
				// Skip errors
			}
		}
	}

	function getTargetEvents()
	{
		$out = array();

		foreach ($this->ruleSet->getRules() as $rule) {
			$out = array_merge($out, $this->findTrigger($rule));
		}

		return $out;
	}

	private function findTrigger($element)
	{
		if ($element->getType() == 'event-trigger') {
{'fraction_non_alphanumeric': 0.1432, 'fraction_numerical': 0.0064, 'mean_word_length': 4.156701030927835, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '663657', 'n_tokens_mistral': 908, 'n_tokens_neox': 805, 'n_words': 214}