It appears that when a person updates their profile picture, their image becomes broken in my feed. Anyone have a solution for this?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna’s picture

Version: 7.x-6.0-alpha2 » 7.x-6.x-dev
Status: Needs work » Active

Please leave the issue status at "Active" when you open an issue, "Needs work" is for when someone uploads a patch but the patch itself needs work. Thanks for opening the issue!

DamienMcKenna’s picture

Status: Active » Postponed (maintainer needs more info)

Which image is broken - their Drupal user profile pic or their Twitter pic? Can you please provide some example HTML to show what it looks like after they update their account?

kevinchampion’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.2 KB

I believe the issue here is that the twitter account profile information can become outdated, specifically the data retrieved from the users_show API endpoint. This includes the twitter account profile image url stored in twitter_account->profile_image_url.

Steps to reproduce

- Add an unauthenticated twitter account
- Confirm that the account's profile photo was correctly retrieved and displays on the listing page
- Change the twitter accounts profile photo on twitter.com
- Confirm that the account's profile photo on the listing page is now a broken image

This user data is retrieved from users_show API endpoint, which only gets called when an authentication attempt happens in twitter_signin.module or when a user (authenticated or unauthenticated) is added at admin/config/services/twitter. Since in most cases the data is only retrieved once, there's no facility to keep it up-to-date over time. So, when a user updates their profile photo on twitter.com, twitter removes the previous profile photo and this leads to the broken images.

Fixing this could be a user-triggered configuration action, but it seems better as an automated routine that runs periodically in the background to keep the data up-to-date. The attached patch does just that by adding a call to make a request to users_show in an effort to update the twitter profile information stored in Drupal.

LiamPower’s picture

Patch works for me

DamienMcKenna’s picture

FileSize
1.55 KB

The new function needed a little tweaking to handle the auth process better.

LiamPower’s picture

Patch #5 also works for me.

kevinchampion’s picture

Found that an outdated profile could be present in the list of users (for instance if a Twitter account was deleted), which causes breakage. Added a check on the returned data from Twitter to prevent such a problem.

Interdiff 5-7

diff --git a/twitter.module b/twitter.module
index aa159ca..c1616b6 100644
--- a/twitter.module
+++ b/twitter.module
@@ -272,7 +272,10 @@ function twitter_cron() {
         }
 
         // Fetch user account to update account information.
-        $twitter_account = twitter_fetch_user_account($twitter_account->twitter_uid);
+        $updated_twitter_account = twitter_fetch_user_account($twitter_account->twitter_uid);
+        if (isset($updated_twitter_account->twitter_uid)) {
+          $twitter_account = $updated_twitter_account;
+        }
 
         // Mark the time this account was updated.
         $twitter_account->last_refresh = REQUEST_TIME;
LiamPower’s picture

The patch from #7 breaks as twitter_fetch_user_account required a $twitter_account as an object, not just the ID.

Added a fixed patch.

rossb89’s picture

Just ran into this issue, confirmed patch #8 seems to do the trick!

I haven't tested thoroughly if this impacts anything else as we only have a very simple use case of pulling in some tweets and displaying them in a view. But running the site cron after the patch applied results in the profile information being updated as intended with no errors / warnings on cron etc.