<commit_before><?php

class sfRavenClient extends Raven_Client
{
  protected function get_user_data()
  {
    if (!sfContext::hasInstance())
    {
      return parent::get_user_data();
    }

    $context = sfContext::getInstance();
    $user = $context->getUser();

    if (!$user)
    {
      return parent::get_user_data();
    }

    return array(
      'sentry.interfaces.User' => array(
        'is_authenticated' => $user->isAnonymous() ? false : true,
        'id'               => session_id(),
        'username'         => $user->getUserName(),
      )
    );
  }

  protected function get_extra_data()
  {
    if (!sfContext::hasInstance())
    {
      return array();
    }

    $context = sfContext::getInstance();

    $extra = array(
      'sf_module_name' => $context->getModuleName(),
      'sf_action_name' => $context->getActionName(),
    );

    if ($conf = $context->getConfiguration())
    {
      $extra['sf_environment'] = $conf->getEnvironment();
    }

    if ($user = $context->getUser())
    {
      $credentials = '';
      if ($user->isAnonymous())
      {
      }
      elseif ($user->isSuperAdmin())
      {
        $credentials = 'Super admin';
      }
      elseif (method_exists($user, 'listCredentials'))
      {
        $credentials = implode(', ' , $user->listCredentials());
      }

      $extra['sf_user_credentials'] = $credentials;
      $extra['sf_user_attributes'] = $user->getAttributeHolder()->getAll();
    }

    return $extra;
  }
}<commit_msg>Ensure user is available in sfRavenClient<commit_after><?php

class sfRavenClient extends Raven_Client
{
  protected function get_user_data()
  {
    if (!sfContext::hasInstance())
    {
      return parent::get_user_data();
    }

    $context = sfContext::getInstance();
    $user = $context->getUser();

    if (!$user || null === $user->getGuardUser())
    {
      return parent::get_user_data();
    }

    return array(
      'sentry.interfaces.User' => array(
        'is_authenticated' => $user->isAnonymous() ? false : true,
        'id'               => session_id(),
        'username'         => $user->getUserName(),
      )
    );
  }

  protected function get_extra_data()
  {
    if (!sfContext::hasInstance())
    {
      return array();
    }

    $context = sfContext::getInstance();

    $extra = array(
      'sf_module_name' => $context->getModuleName(),
      'sf_action_name' => $context->getActionName(),
    );

    if ($conf = $context->getConfiguration())
    {
      $extra['sf_environment'] = $conf->getEnvironment();
    }

    if (($user = $context->getUser()) && null !== $user->getGuardUser())
    {
      $credentials = '';
      if ($user->isAnonymous())
      {
      }
      elseif ($user->isSuperAdmin())
      {
        $credentials = 'Super <PASSWORD>';
      }
      elseif (method_exists($user, 'listCredentials'))
      {
        $credentials = implode(', ' , $user->listCredentials());
      }

      $extra['sf_user_credentials'] = $credentials;
      $extra['sf_user_attributes'] = $user->getAttributeHolder()->getAll();
    }

    return $extra;
  }
}
{'fraction_non_alphanumeric': 0.16995153473344105, 'fraction_numerical': 0.0, 'mean_word_length': 2.502262443438914, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 44, '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': '1332481', 'n_tokens_mistral': 968, 'n_tokens_neox': 951, 'n_words': 159}