Comments

HLopes created an issue. See original summary.

hlopes’s picture

gvso’s picture

Status: Active » Needs work
+++ b/src/Plugin/Network/TwitterAuth.php
@@ -84,6 +85,30 @@ class TwitterAuth extends SocialAuthNetwork implements TwitterAuthInterface {
+    $http_client = Settings::get('http_client_config');

Thanks for reporting this and providing a patch. The only change I suggest is to inject the site settings object. Look at other implementers such as Auth Google for guidance on how to do this.

hlopes’s picture

StatusFileSize
new3.5 KB
gvso’s picture

Thanks!

  1. +++ b/src/Plugin/Network/TwitterAuth.php
    @@ -62,11 +64,21 @@ class TwitterAuth extends SocialAuthNetwork implements TwitterAuthInterface {
    +  ) {
    

    This should be at the same line as the last parameter

  2. +++ b/src/Plugin/Network/TwitterAuth.php
    @@ -62,11 +64,21 @@ class TwitterAuth extends SocialAuthNetwork implements TwitterAuthInterface {
    +    $this->siteSettings = $settings;
    

    siteSettings was not declared before this statement.

  3. +++ b/src/Plugin/Network/TwitterAuth.php
    @@ -84,6 +96,10 @@ class TwitterAuth extends SocialAuthNetwork implements TwitterAuthInterface {
    +    if ($proxy = $this->getProxy()) {
    

    Assignment in condition

  4. +++ b/src/Plugin/Network/TwitterAuth.php
    @@ -101,8 +117,37 @@ class TwitterAuth extends SocialAuthNetwork implements TwitterAuthInterface {
    +    $proxyUrl = $this->siteSettings->get('http_client_config')['proxy']['https'] ?? NULL;
    

    Coalescing operator is only supported in PHP 7

Remember to change the status to Needs review.

hlopes’s picture

Status: Needs work » Needs review
StatusFileSize
new3.99 KB
gvso’s picture

Status: Needs review » Needs work

Thanks!

+++ b/src/Plugin/Network/TwitterAuth.php
@@ -101,8 +124,42 @@ class TwitterAuth extends SocialAuthNetwork implements TwitterAuthInterface {
+    $proxyUrl = $this->siteSettings->get('http_client_config')['proxy']['https']
+      ? $this->siteSettings->get('http_client_config')['proxy']['https']
+      : NULL;

Method get returns NULL if setting was not set. So, I guess you can just do $proxyUrl = $this->siteSettings->get('http_client_config')['proxy']['http'];

Also, remember to include interdiff.

hlopes’s picture

Status: Needs work » Needs review
StatusFileSize
new3.9 KB
new564 bytes

  • gvso committed 3751d49 on 8.x-2.x authored by HLopes
    Issue #2952324 by HLopes: Proxy support
    
gvso’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ariane’s picture

StatusFileSize
new202.74 KB

Sorry for re-opening the issue but... As seen in the attached image it throws me an error after the login.

I have put a simple checking line with an isset before getting $this->siteSettings->get('http_client_config')['proxy']['https'] and now it works ok for me.

private function getProxy() {
    $proxy = NULL;
    if(isset($this->siteSettings->get('http_client_config')['proxy'])){   
      $proxyUrl = $this->siteSettings->get('http_client_config')['proxy']['https'];

      if ($proxyUrl) {
        $proxy_settings = parse_url($proxyUrl);

        if ($proxy_settings) {
          $proxy = [
            'CURLOPT_PROXY' => $proxy_settings['host'],
            'CURLOPT_PROXYUSERPWD' => "{$proxy_settings['user']}:{$proxy_settings['pass']}",
            'CURLOPT_PROXYPORT' => $proxy_settings['port'],
          ];
        }
      }    
    }
    return $proxy;
  }

May it helps.

hlopes’s picture

Can you try with the patch in #6 ?

ariane’s picture

I have already the patch installed.