<commit_before><?php

class Profile_Controller_Index extends Default_Controller_LoggedIn
{
    public function indexAction()
    {
        $this->userAttributes = $this->_normalizeAttributes();

        $this->metadata = new EngineBlock_Attributes_Metadata();

        $serviceRegistryClient = $this->_getServiceRegistryClient();
        $this->spList = $serviceRegistryClient->getSpList();

        $this->consent = $this->user->getConsent();
        $this->spAttributesList = $this->_getSpAttributeList($this->consent);

        $this->mailSend = isset($_GET["mailSend"]) ? $_GET["mailSend"] : null;
    }

    /**
     * Returns an array with attributes that are released to each SP.
     *
     * We check if there is an ARP and then return this otherwise all attributes we have gotten.
     *
     * @param array $spList all service providers
     * @return array with service providers Id's with the ARP
     */
    protected function _getSpAttributeList(array $spList)
    {
        $attributes = $this->_normalizeAttributes();

        $results = array();
        $serviceRegistryClient = $this->_getServiceRegistryClient();
        $enforcer = new EngineBlock_Arp_AttributeReleasePolicyEnforcer();
        foreach ($spList as $spId) {
            $arp = $serviceRegistryClient->getArp($spId);
            $results[$spId] = $enforcer->enforceArp($arp, $attributes);
        }

        return $results;
    }

    /**
     * Return the cleansed attributes
     */
    protected function _normalizeAttributes()
    {
        $normalizer = new EngineBlock_Attributes_Normalizer($this->attributes);
        $normalizedAttributes = $normalizer->normalize();
        unset($normalizedAttributes['nameid']);
        return $normalizedAttributes;
    }

    /**
     * @return Janus_Client
     */
    protected function _getServiceRegistryClient()
    {
        $serviceRegistryClient = EngineBlock_ApplicationSingleton::getInstance()->getDiContainer()->getServiceRegistryClient();
        return $serviceRegistryClient;
    }
}<commit_msg>Improvement to bugfix for issue #105. Don't try to get the ARP for legacy SPs.<commit_after><?php

class Profile_Controller_Index extends Default_Controller_LoggedIn
{
    public function indexAction()
    {
        $this->userAttributes = $this->_normalizeAttributes();

        $this->metadata = new EngineBlock_Attributes_Metadata();

        $serviceRegistryClient = $this->_getServiceRegistryClient();
        $this->spList = $serviceRegistryClient->getSpList();

        $this->consent = $this->user->getConsent();
        $this->spAttributesList = $this->_getSpAttributeList($this->consent);

        $this->mailSend = isset($_GET["mailSend"]) ? $_GET["mailSend"] : null;
    }

    /**
     * Returns an array with attributes that are released to each SP.
     *
     * We check if there is an ARP and then return this otherwise all attributes we have gotten.
     *
     * @param array $spList all service providers
     * @return array with service providers Id's with the ARP
     */
    protected function _getSpAttributeList(array $spList)
    {
        $attributes = $this->_normalizeAttributes();

        $results = array();
        $serviceRegistryClient = $this->_getServiceRegistryClient();
        $enforcer = new EngineBlock_Arp_AttributeReleasePolicyEnforcer();
        foreach ($spList as $spId) {
            if (!isset($this->spList[$spId])) {
                continue;
            }

            $arp = $serviceRegistryClient->getArp($spId);
            $results[$spId] = $enforcer->enforceArp($arp, $attributes);
        }

        return $results;
    }

    /**
     * Return the cleansed attributes
     */
    protected function _normalizeAttributes()
    {
        $normalizer = new EngineBlock_Attributes_Normalizer($this->attributes);
        $normalizedAttributes = $normalizer->normalize();
        unset($normalizedAttributes['nameid']);
        return $normalizedAttributes;
    }

    /**
     * @return Janus_Client
     */
    protected function _getServiceRegistryClient()
    {
        $serviceRegistryClient = EngineBlock_ApplicationSingleton::getInstance()->getDiContainer()->getServiceRegistryClient();
        return $serviceRegistryClient;
    }
}
{'fraction_non_alphanumeric': 0.11425873465533522, 'fraction_numerical': 0.000708215297450425, 'mean_word_length': 3.004725897920605, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 46, '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': '4884916', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1103, 'n_words': 249}