<commit_before><?php

/*
 * This file comes the symfony package (originally sfCacheFilter.class.php) and has been reworked by me (vdb).
 */

class MyCacheFilter extends sfCacheFilter
{
  protected
    $cacheManager = null,
    $request      = null,
    $response     = null,
    $cache        = array(),
    $interface_language = null, // added
    $credentials  = null; // added

  /**
   * Initializes this Filter.
   *
   * @param sfContext The current application context
   * @param array   An associative array of initialization parameters
   *
   * @return bool true, if initialization completes successfully, otherwise false
   *
   * @throws <b>sfInitializationException</b> If an error occurs while initializing this Filter
   */
  public function initialize($context, $parameters = array())
  {
    parent::initialize($context, $parameters);

    $this->cacheManager = $context->getViewCacheManager();
    $this->request      = $context->getRequest();
    $this->response     = $context->getResponse();
    
    $user = $this->getContext()->getUser(); 
    // replaced $context by getcontext to get latest available context, so that cache presents true user connected status.
    $this->interface_language = $user->getCulture(); 
    $this->credentials = (int)$user->isConnected() + (int)$user->hasCredential('moderator'); 
    // anonymous : 0
    // connected : 1
    // moderator : 2
  }

    public static function getCurrentCacheUri()
    {
        // for home, portals filter and default list, we adapt cache uri so that we can cache
        // cases where all cultures are displayed, or only the one from the interface (see #723)
        $context = sfContext::getInstance();
        $module = $context->getModuleName();
        $action = $context->getActionName();
        
        $request_parameters = $context->getRequest()->getParameterHolder()->getAll();
        unset($request_parameters['module']);
        unset($request_parameters['action']);
        
        $is_cacheable_filter_list = false;
        if (in_array($action, array('filter', 'list')))
        {
            $count_request_parameters = count($request_parameters);
                
            switch($action)
            {
                case 'list':
                    if (!isset($request_parameters['page']))
                    {
                        $request_parameters['page'] = 1;
                        $count_request_parameters++;
                    }
                    if (    $request_parameters['page'] <= 2
                         && (   $count_request_parameters == 1
                             || (   $module == 'outings'
                                 && $count_request_parameters == 3
                                 && isset($request_parameters['orderby'])
                                 && $request_parameters['orderby'] == 'date'
                                 && isset($request_parameters['order'])
                                 && $request_parameters['order'] == 'desc'
                                )
                            )
                       )
                    {
                        $is_cacheable_filter_list = true;
                    }
                    break;
                
                case 'filter';
                    if (!count($request_parameters))
                    {
                        $is_cacheable_filter_list = true;
                    }
                    break;
                
                default:
                    break;
            }
        }
        
        $uri = sfRouting::getInstance()->getCurrentInternalUri();
        if ($action == 'view')
        {
            $uri_tmp = explode('&slug=', $uri);
            $uri = $uri_tmp[0];
        }
        $il = 'il=' . $context->getUser()->getCulture();
        $pl = '';
        $pa = '';
        $credential = ((int)$context->getUser()->isConnected() + (int)$context->getUser()->hasCredential('moderator'));
        $c = '&c=' . $credential;
        
        if ($action == 'home' || $module == 'portals' && $action == 'view' || $is_cacheable_filter_list)
        {
            if ($action == 'home' || $module == 'portals' && $action == 'view')
            {
                $module_cache = 'outings';
            }
            else
            {
                $module_cache = $module;
            }
            $perso = c2cPersonalization::getInstance();
            list($langs_enable, $areas_enable, $activities_enable) = c2cPersonalization::getDefaultFilters($module_cache);
            $is_main_filter_switch_on = $perso->isMainFilterSwitchOn();
            $activities_filter = $perso->getActivitiesFilter();
            
            if ($is_main_filter_switch_on)
            {
                if (   $action != 'filter'
                    && (   $action != 'list'
                        || $langs_enable
                       )
                    && $perso->areDefaultLanguagesFilters()
                   )
                {
                    $pl = '&pl=1';<commit_msg>slug and cache<commit_after><?php

/*
 * This file comes the symfony package (originally sfCacheFilter.class.php) and has been reworked by me (vdb).
 */

class MyCacheFilter extends sfCacheFilter
{
  protected
    $cacheManager = null,
    $request      = null,
    $response     = null,
    $cache        = array(),
    $interface_language = null, // added
    $credentials  = null; // added

  /**
   * Initializes this Filter.
   *
   * @param sfContext The current application context
   * @param array   An associative array of initialization parameters
   *
   * @return bool true, if initialization completes successfully, otherwise false
   *
   * @throws <b>sfInitializationException</b> If an error occurs while initializing this Filter
   */
  public function initialize($context, $parameters = array())
  {
    parent::initialize($context, $parameters);

    $this->cacheManager = $context->getViewCacheManager();
    $this->request      = $context->getRequest();
    $this->response     = $context->getResponse();
    
    $user = $this->getContext()->getUser(); 
    // replaced $context by getcontext to get latest available context, so that cache presents true user connected status.
    $this->interface_language = $user->getCulture(); 
    $this->credentials = (int)$user->isConnected() + (int)$user->hasCredential('moderator'); 
    // anonymous : 0
    // connected : 1
    // moderator : 2
  }

    public static function getCurrentCacheUri()
    {
        // for home, portals filter and default list, we adapt cache uri so that we can cache
        // cases where all cultures are displayed, or only the one from the interface (see #723)
        $context = sfContext::getInstance();
        $module = $context->getModuleName();
        $action = $context->getActionName();
        
        $request_parameters = $context->getRequest()->getParameterHolder()->getAll();
        unset($request_parameters['module']);
        unset($request_parameters['action']);
        
        $is_cacheable_filter_list = false;
        if (in_array($action, array('filter', 'list')))
        {
            $count_request_parameters = count($request_parameters);
                
            switch($action)
            {
                case 'list':
                    if (!isset($request_parameters['page']))
                    {
                        $request_parameters['page'] = 1;
                        $count_request_parameters++;
                    }
                    if (    $request_parameters['page'] <= 2
                         && (   $count_request_parameters == 1
                             || (   $module == 'outings'
                                 && $count_request_parameters == 3
                                 && isset($request_parameters['orderby'])
                                 && $request_parameters['orderby'] == 'date'
                                 && isset($request_parameters['order'])
                                 && $request_parameters['order'] == 'desc'
                                )
                            )
                       )
                    {
                        $is_cacheable_filter_list = true;
                    }
                    break;
                
                case 'filter';
                    if (!count($request_parameters))
                    {
                        $is_cacheable_filter_list = true;
                    }
                    break;
                
                default:
                    break;
            }
        }
        
        $uri = sfRouting::getInstance()->getCurrentInternalUri();
        $il = 'il=' . $context->getUser()->getCulture();
        $pl = '';
        $pa = '';
        $credential = ((int)$context->getUser()->isConnected() + (int)$context->getUser()->hasCredential('moderator'));
        $c = '&c=' . $credential;
        
        if ($action == 'home' || $module == 'portals' && $action == 'view' || $is_cacheable_filter_list)
        {
            if ($action == 'home' || $module == 'portals' && $action == 'view')
            {
                $module_cache = 'outings';
            }
            else
            {
                $module_cache = $module;
            }
            $perso = c2cPersonalization::getInstance();
            list($langs_enable, $areas_enable, $activities_enable) = c2cPersonalization::getDefaultFilters($module_cache);
            $is_main_filter_switch_on = $perso->isMainFilterSwitchOn();
            $activities_filter = $perso->getActivitiesFilter();
            
            if ($is_main_filter_switch_on)
            {
                if (   $action != 'filter'
                    && (   $action != 'list'
                        || $langs_enable
                       )
                    && $perso->areDefaultLanguagesFilters()
                   )
                {
                    $pl = '&pl=1';
{'fraction_non_alphanumeric': 0.122916248242619, 'fraction_numerical': 0.0027113878288813013, 'mean_word_length': 1.5366785532348446, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '356411', 'n_tokens_mistral': 2522, 'n_tokens_neox': 2441, 'n_words': 521}