• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed Delete saved user identifiy data on identify service delete

R

ragtek

Guest
#1
As you see in this thread: http://xenforo.com/community/thread...messenger-id-to-be-visible-in-profiles.18319/ the stored user data aren't deleted, if you delete a identify service.

If you delete a identify service, the user will have a ugly:
identity_service_name_yahoo: xxx on his profile

as you see in dw, you're only deleting the phrases:
PHP:
    /**
    * Post-delete handling.
    */
    protected function _postDelete()
    {
        $this->_deleteMasterPhrase($this->_getNamePhraseName($this->get('identity_service_id')));
        $this->_deleteMasterPhrase($this->_getHintPhraseName($this->get('identity_service_id')));
    }
 

Attachments

R

ragtek

Guest
#2
I've tried to add this to the dm:

PHP:
protected function _postDelete()
    {
        $this->_deleteMasterPhrase($this->_getNamePhraseName($this->get('identity_service_id')));
        $this->_deleteMasterPhrase($this->_getHintPhraseName($this->get('identity_service_id')));
 
        $db = $this->_db;

        $id = $db->quote($this->get('identity_service_id'));
        $db->delete('xf_user_identity', 'identity_service_id = ' . $id);
    }
but that's not enough, because the identity data are also saved serialized in the xf_user_profile :(
 
R

ragtek

Guest
#3
I couldn't go out of the office without a bugfix for this:d

so, if anybody is interested in this and want to fix it, before kier & mike fix it in the core:
file: XenForo_DataWriter_IdentityService
PHP:
        protected function _postDelete()

        {
            $this->_deleteMasterPhrase($this->_getNamePhraseName($this->get('identity_service_id')));
            $this->_deleteMasterPhrase($this->_getHintPhraseName($this->get('identity_service_id')));


            $db = $this->_db;

            $id = $db->quote($this->get('identity_service_id'));

            $where = "identity_service_id = " . $id;

            $users = $db->fetchAll("select user_id from xf_user_identity where " . $where);
           

            foreach ($users AS $user){
                /** @var $dw XenForo_DataWriter_User */
                $dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
                $dw->setExistingData($user);
                $dw->setIdentity($this->get('identity_service_id'), '');
                $dw->save();
            }
            $db->delete('xf_user_identity', $where);
            
        }