Explorar el Código

fix: chhoto URL fallback, found by tests

El RIDO hace 1 semana
padre
commit
37088dadfa
Se han modificado 2 ficheros con 12 adiciones y 5 borrados
  1. 11 3
      lib/Proxy/AbstractProxy.php
  2. 1 2
      lib/Proxy/ChhotoProxy.php

+ 11 - 3
lib/Proxy/AbstractProxy.php

@@ -30,6 +30,14 @@ abstract class AbstractProxy
      */
     private $_error = '';
 
+    /**
+     * proxy URL
+     *
+     * @access protected
+     * @var    string
+     */
+    protected $_proxyUrl = '';
+
     /**
      * shortened URL
      *
@@ -61,15 +69,15 @@ abstract class AbstractProxy
             return;
         }
 
-        $proxyUrl = $this->_getProxyUrl($conf);
+        $this->_proxyUrl = $this->_getProxyUrl($conf);
 
-        if (empty($proxyUrl)) {
+        if (empty($this->_proxyUrl)) {
             $this->_error = 'Proxy error: Proxy URL is empty. This can be a configuration issue, like wrong or missing config keys.';
             $this->logErrorWithClassName($this->_error);
             return;
         }
 
-        $data = file_get_contents($proxyUrl, false,
+        $data = file_get_contents($this->_proxyUrl, false,
             stream_context_create(
                 [
                     'http' => $this->_getProxyPayload($conf, $link),

+ 1 - 2
lib/Proxy/ChhotoProxy.php

@@ -82,8 +82,7 @@ class ChhotoProxy extends AbstractProxy
 
         // Fallback for older versions that return only the slug
         if (!empty($data['shortlink'])) {
-            $apiUrl = $this->_getProxyUrl(new Configuration()); // not ideal, but works
-            return $apiUrl . ltrim($data['shortlink'], '/');
+            return $this->_proxyUrl . ltrim($data['shortlink'], '/');
         }
 
         return null;