<commit_before><?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 <NAME> <<EMAIL>>
 * (c) 2004-2006 <NAME>.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * sfExecutionFilter is the last filter registered for each filter chain. This
 * filter does all action and view execution.
 *
 * @package    symfony
 * @subpackage filter
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id$
 */
class sfExecutionFilter extends sfFilter
{
  /**
   * Execute this filter.
   *
   * @param sfFilterChain The filter chain.
   *
   * @return void
   *
   * @throws <b>sfInitializeException</b> If an error occurs during view initialization.
   * @throws <b>sfViewException</b>       If an error occurs while executing the view.
   */
  public function execute ($filterChain)
  {
    // get the context and controller
    $context    = $this->getContext();
    $controller = $context->getController();

    // get the current action instance
    $actionEntry    = $controller->getActionStack()->getLastEntry();
    $actionInstance = $actionEntry->getActionInstance();

    // get the current action information
    $moduleName = $context->getModuleName();
    $actionName = $context->getActionName();

    // get the request method
    $method = $context->getRequest()->getMethod();

    $viewName = null;

    if (sfConfig::get('sf_cache') && !sfConfig::get('sf_cache_always_execute_action', false))
    {
      list($uri, $suffix) = $context->getViewCacheManager()->getInternalUri('slot');
      if ($context->getResponse()->getParameter($uri.'_'.$suffix, null, 'symfony/cache') !== null)
      {
        // action in cache, so go to the view
        $viewName = sfView::RENDER_CACHE;
      }
    }

    if (!$viewName)
    {
      // create validator manager
      $validatorManager = new sfValidatorManager();
      $validatorManager->initialize($context);

      if (($actionInstance->getRequestMethods() & $method) != $method)
      {
        // this action will skip validation/execution for this method
        // get the default view
        $viewName = $actionInstance->getDefaultView();
      }
      else
      {
        // set default validated status
        $validated = true;

        // process manual validation
        $validateToRun = 'validate'.ucfirst($actionName);
        $validated = method_exists($actionInstance, $validateToRun) ? $actionInstance->$validateToRun() : $actionInstance->validate();

        if ($validated)
        {
          // get the current action validation configuration
          $validationConfig = $moduleName.'/'.sfConfig::get('sf_app_module_validate_dir_name').'/'.$actionName.'.yml';
          if (is_readable(sfConfig::get('sf_app_module_dir').'/'.$validationConfig))
          {
            // load validation configuration
            // do NOT use require_once
            require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$validationConfig));
          }

          // manually load validators
          $actionInstance->registerValidators($validatorManager);

          // process validators
          $validated = $validatorManager->execute();
        }

        $sf_logging_active = sfConfig::get('sf_logging_active');
        if ($validated)
        {
          // execute the action
          $actionInstance->preExecute();
          $viewName = $actionInstance->execute();
          if ($viewName == '')
          {
            $viewName = sfView::SUCCESS;
          }
          $actionInstance->postExecute();
        }
        else
        {
          if ($sf_logging_active)
          {
            $this->context->getLogger()->info('{sfExecutionFilter} action validation failed');
          }

          // validation failed
          $handleErrorToRun = 'handleError'.ucfirst($actionName);
          $viewName = method_exists($actionInstance, $handleErrorToRun) ? $actionInstance->$handleErrorToRun() : $actionInstance->handleError();
        }<commit_msg>fixes validation - now all validators are run (closes #212)<commit_after><?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 <NAME> <<EMAIL>>
 * (c) 2004-2006 <NAME>.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * sfExecutionFilter is the last filter registered for each filter chain. This
 * filter does all action and view execution.
 *
 * @package    symfony
 * @subpackage filter
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id$
 */
class sfExecutionFilter extends sfFilter
{
  /**
   * Execute this filter.
   *
   * @param sfFilterChain The filter chain.
   *
   * @return void
   *
   * @throws <b>sfInitializeException</b> If an error occurs during view initialization.
   * @throws <b>sfViewException</b>       If an error occurs while executing the view.
   */
  public function execute ($filterChain)
  {
    // get the context and controller
    $context    = $this->getContext();
    $controller = $context->getController();

    // get the current action instance
    $actionEntry    = $controller->getActionStack()->getLastEntry();
    $actionInstance = $actionEntry->getActionInstance();

    // get the current action information
    $moduleName = $context->getModuleName();
    $actionName = $context->getActionName();

    // get the request method
    $method = $context->getRequest()->getMethod();

    $viewName = null;

    if (sfConfig::get('sf_cache') && !sfConfig::get('sf_cache_always_execute_action', false))
    {
      list($uri, $suffix) = $context->getViewCacheManager()->getInternalUri('slot');
      if ($context->getResponse()->getParameter($uri.'_'.$suffix, null, 'symfony/cache') !== null)
      {
        // action in cache, so go to the view
        $viewName = sfView::RENDER_CACHE;
      }
    }

    if (!$viewName)
    {
      // create validator manager
      $validatorManager = new sfValidatorManager();
      $validatorManager->initialize($context);

      if (($actionInstance->getRequestMethods() & $method) != $method)
      {
        // this action will skip validation/execution for this method
        // get the default view
        $viewName = $actionInstance->getDefaultView();
      }
      else
      {
        // set default validated status
        $validated = true;

        // get the current action validation configuration
        $validationConfig = $moduleName.'/'.sfConfig::get('sf_app_module_validate_dir_name').'/'.$actionName.'.yml';
        if (is_readable(sfConfig::get('sf_app_module_dir').'/'.$validationConfig))
        {
          // load validation configuration
          // do NOT use require_once
          require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$validationConfig));
        }

        // manually load validators
        $actionInstance->registerValidators($validatorManager);

        // process validators
        $validated = $validatorManager->execute();

        // process manual validation
        $validateToRun = 'validate'.ucfirst($actionName);
        $manualValidated = method_exists($actionInstance, $validateToRun) ? $actionInstance->$validateToRun() : $actionInstance->validate();

        // action is validated only if both validators returned true
        $validated = $manualValidated && $validated;

        $sf_logging_active = sfConfig::get('sf_logging_active');
        if ($validated)
        {
          // execute the action
          $actionInstance->preExecute();
          $viewName = $actionInstance->execute();
          if ($viewName == '')
          {
            $viewName = sfView::SUCCESS;
          }
          $actionInstance->postExecute();
        }
        else
        {
          if ($sf_logging_active)
          {
            $this->context->getLogger()->info('{sfExecutionFilter} action validation failed');
          }

          // validation failed
          $handleErrorToRun = 'handleError'.ucfirst($actionName);
          $viewName = method_exists($actionInstance, $handleErrorToRun) ? $actionInstance->$handleErrorToRun() : $actionInstance->handleError();
        }
{'fraction_non_alphanumeric': 0.13063875857091303, 'fraction_numerical': 0.004210273066281727, 'mean_word_length': 2.680389552899513, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 89, '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': '1870464', 'n_tokens_mistral': 2270, 'n_tokens_neox': 2213, 'n_words': 544}