XF 2.2 Where is the user_connected_account cache stored?

Jaxel

Well-known member
If an entry is removed from xf_user_connected_account, the entry is still visible in the front end... and you can't disassociate it, as the system can't find the entry to disassociate, since it doesn't exist. How do I remove this entry?
 

Chris D

XenForo developer
Staff member
The connected accounts cache is stored in the xf_user_profile table in the connected_accounts field.

The behaviour you have described is unexpected so I would check to ensure there isn't any add-ons installed which might be doing something unusual on post save or post delete in the UserConnectedAccount entity as it is then when the xf_user_profile.connected_accounts field is updated..
 

Jaxel

Well-known member
I would think the behavior is completely expected.

Even if I manually deleted the entry from xf_user_connected_account, it will still show up, because the entry is still in xf_user_profile.connected_accounts.

Then, I can't disassociate the account, because the entry does not exist anymore in xf_user_connected_account.
 

Chris D

XenForo developer
Staff member
Well yes. It’s expected if you manually delete it. I assumed it had been deleted properly and something had stopped the cache from updating because usually manually deleting anything isn’t wise.

Associating or disassociating some other connected account on the account would rebuild it.
 

Jaxel

Well-known member
Well yes. It’s expected if you manually delete it. I assumed it had been deleted properly and something had stopped the cache from updating because usually manually deleting anything isn’t wise.

Associating or disassociating some other connected account on the account would rebuild it.

Yeah. But if I have an uninstall script that removes all the connected accounts for my addon... how would I then have it rebuild all the caches afterwards?
 

Jaxel

Well-known member
I would think the rebuild user caches function in the admin CP would do it... but it doesn't.
 

Chris D

XenForo developer
Staff member
I would think the rebuild user caches function in the admin CP would do it... but it doesn't.
It should do.

That's one of the actions called in the user rebuild job:

PHP:
$user->Profile->rebuildUserFieldValuesCache();
 

Jaxel

Well-known member
It should do.

That's one of the actions called in the user rebuild job:

PHP:
$user->Profile->rebuildUserFieldValuesCache();

I traced through it, that function does not rebuild user connected accounts:
Code:
$this->repository('XF:UserField')->rebuildUserFieldValuesCache($this->user_id);

The function that would do it would be:
Code:
$this->repository('XF:ConnectedAccount')->rebuildUserConnectedAccountCache($user);

Is this an oversight?
 

Chris D

XenForo developer
Staff member
Sorry that's a fair point. It's been a long day.

I'm not sure it's an oversight exactly, but tracing the code through I'm not sure why you would be seeing an entry to disassociate the connected account provider.

You mention you have "removed all the connected accounts" which is presumably the records from the xf_user_connected_account table. Are you not removing the connected account provider too from xf_connected_account_provider? If you do that, then the connected account won't display as associated anymore.

Unless there's a reason you're deleting the existing associated accounts but leaving the provider there for some reason. Which is not an oversight, exactly, but rather an unexpected use case.
 

Jaxel

Well-known member
It's an unexpected use case.

What I'm asking is, if it's an oversight that rebuilding the user cache, does not also rebuild the user connected accounts cache as well.
 
Top