From d1f10639005c01999fcdbe01540b841f457f4546 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Fri, 23 Oct 2015 16:19:54 +0000 Subject: [PATCH 1/3] Twitter URIs have changed The #! was deprecated ages ago, and Twitter forces HTTPS these days. --- plugins/TwitterBridge/lib/twitterimport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/TwitterBridge/lib/twitterimport.php b/plugins/TwitterBridge/lib/twitterimport.php index d929fecf83..e4621df90c 100644 --- a/plugins/TwitterBridge/lib/twitterimport.php +++ b/plugins/TwitterBridge/lib/twitterimport.php @@ -209,7 +209,7 @@ class TwitterImport */ function makeStatusURI($username, $id) { - return 'http://twitter.com/#!/' + return 'https://twitter.com/' . $username . '/status/' . $id; From 439b466979eb1e1d3f0445b9f84fc69ac6276ae5 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Fri, 23 Oct 2015 16:24:04 +0000 Subject: [PATCH 2/3] Use HTTPS for links to Twitter profiles as well --- plugins/TwitterBridge/lib/twitterimport.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/TwitterBridge/lib/twitterimport.php b/plugins/TwitterBridge/lib/twitterimport.php index e4621df90c..70c9093fa2 100644 --- a/plugins/TwitterBridge/lib/twitterimport.php +++ b/plugins/TwitterBridge/lib/twitterimport.php @@ -241,6 +241,16 @@ class TwitterImport protected function ensureProfile($twuser) { // check to see if there's already a profile for this user + $profileurl = 'https://twitter.com/' . $twuser->screen_name; + try { + $profile = $this->getProfileByUrl($twuser->screen_name, $profileurl); + $this->updateAvatar($twuser, $profile); + return $profile; + } catch (NoResultException $e) { + common_debug(__METHOD__ . ' - Falling back to check for http: ' . + "for Twitter user: $profileurl."); + } + $profileurl = 'http://twitter.com/' . $twuser->screen_name; try { $profile = $this->getProfileByUrl($twuser->screen_name, $profileurl); @@ -527,9 +537,9 @@ class TwitterImport static function atLink($screenName, $fullName, $orig) { if (!empty($fullName)) { - return "{$orig}"; + return "{$orig}"; } else { - return "{$orig}"; + return "{$orig}"; } } From 2030ddfc7992f4c36cfb2123b250c6c88e9bf44c Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Fri, 23 Oct 2015 16:26:35 +0000 Subject: [PATCH 3/3] Reduce duplication by handling both cases in find --- plugins/TwitterBridge/lib/twitterimport.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/plugins/TwitterBridge/lib/twitterimport.php b/plugins/TwitterBridge/lib/twitterimport.php index 70c9093fa2..d9858ca968 100644 --- a/plugins/TwitterBridge/lib/twitterimport.php +++ b/plugins/TwitterBridge/lib/twitterimport.php @@ -233,7 +233,10 @@ class TwitterImport $profile->limit(1); if (!$profile->find(true)) { - throw new NoResultException($profile); + $profile->profileurl = str_replace('https://', 'http://', $profileurl); + if (!$profile->find(true)) { + throw new NoResultException($profile); + } } return $profile; } @@ -242,16 +245,6 @@ class TwitterImport { // check to see if there's already a profile for this user $profileurl = 'https://twitter.com/' . $twuser->screen_name; - try { - $profile = $this->getProfileByUrl($twuser->screen_name, $profileurl); - $this->updateAvatar($twuser, $profile); - return $profile; - } catch (NoResultException $e) { - common_debug(__METHOD__ . ' - Falling back to check for http: ' . - "for Twitter user: $profileurl."); - } - - $profileurl = 'http://twitter.com/' . $twuser->screen_name; try { $profile = $this->getProfileByUrl($twuser->screen_name, $profileurl); $this->updateAvatar($twuser, $profile);