[BUGFIX] TYPO3 tries to connect to typo3.org on every login
authorSusanne Moog <typo3@susannemoog.de>
Sun, 21 Aug 2011 15:42:31 +0000 (17:42 +0200)
committerSusanne Moog <typo3@susannemoog.de>
Sun, 21 Aug 2011 16:31:08 +0000 (18:31 +0200)
The extension manager tries to establish a connection to the TER
as soon as user credentials for a user are given.

This patch changes that behavior so that it is only done for
the functions that actually need a TER call.

Additionally I did some cleanup.

Change-Id: I4424f71d1b645ffdb46b3319409a48dbe00c7e70
Resolves: #28949
Releases: 4.6, 4.5
Reviewed-on: http://review.typo3.org/4453
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/em/classes/connection/class.tx_em_connection_extdirectsoap.php

index cbceef8..f47d08d 100644 (file)
@@ -56,8 +56,6 @@ class tx_em_Connection_ExtDirectSoap {
 
        /**
         * Constructor
-        *
-        * @return void
         */
        public function __construct() {
                $this->settings = $this->getSettingsObject()->getSettings();
@@ -67,16 +65,21 @@ class tx_em_Connection_ExtDirectSoap {
                if (isset($this->settings['fe_u']) && isset($this->settings['fe_p']) && $this->settings['fe_u'] !== '' && $this->settings['fe_p'] !== '' ) {
                        $this->setAccountData($this->settings['fe_u'], $this->settings['fe_p']);
                }
-
-
        }
 
        /**
         * Login test with user credentials
         *
+        * @deprecated since 4.6, will be removed in 4.8
         * @return array
         */
        public function testUserLogin() {
+
+                       // There is a theory which states that if ever anybody discovers exactly what this method is for and why it is here,
+                       // it will instantly disappear and be replaced by something even more bizarre and inexplicable.
+                       // There is another theory which states that this has already happened.
+               t3lib_div::logDeprecatedFunction();
+
                if (is_array($this->accountData)) {
                        $login = FALSE;
                        if ($login) {
@@ -106,8 +109,8 @@ class tx_em_Connection_ExtDirectSoap {
         * @param  array $record
         * @return string
         */
-       public function  showRemoteExtInfo($record) {
-               return t3lib_div::view_array(array($record, $this->settings));
+       public function showRemoteExtInfo($record) {
+               return t3lib_utility_Debug::viewArray(array($record, $this->settings));
        }
 
        /**
@@ -118,12 +121,12 @@ class tx_em_Connection_ExtDirectSoap {
         * @return array
         */
        public function checkExtensionkey($parameter) {
-           $params = array(
-                       'extensionKey' => $parameter['extkey']
+               $this->initSoap();
+               $params = array(
+                       'extensionKey' => $parameter['extkey']
                );
                $result = $this->soapCall('checkExtensionKey', $params);
                $message = $this->getSoapResultMessageFromCode($result['resultCode']);
-               //debug(array($result,$parameter), $message);
                if ($result['resultCode'] == 10501) {
                        $return =  array(
                                'success' => TRUE,
@@ -150,11 +153,12 @@ class tx_em_Connection_ExtDirectSoap {
         * @return array
         */
        public function registerExtensionkey($parameter) {
-           $params = array(
+               $this->initSoap();
+               $params = array(
                        'registerExtensionKeyData' => array(
-                                'extensionKey' => $parameter['extkey'],
-                                'title' => $parameter['title'],
-                                'description' => $parameter['description']
+                               'extensionKey' => $parameter['extkey'],
+                               'title' => $parameter['title'],
+                               'description' => $parameter['description']
                        )
                );
                $result = $this->soapCall('registerExtensionKey', $params);
@@ -183,7 +187,8 @@ class tx_em_Connection_ExtDirectSoap {
         *
         * @return array
         */
-       public function getExtensions($parameter) {
+       public function getExtensions() {
+               $this->initSoap();
                $params = array(
                        'extensionKeyFilterOptions' => array(
                                'username' => $this->settings['fe_u']
@@ -213,11 +218,12 @@ class tx_em_Connection_ExtDirectSoap {
         * Delete extension key
         *
         * @param  string $key
-        * @return void
+        * @return array
         */
        public function deleteExtensionKey($key) {
+               $this->initSoap();
                $params = array(
-                       'extensionKey' => $key
+                       'extensionKey' => $key
                );
                $result = $this->soapCall('deleteExtensionKey', $params);
                $message = $this->getSoapResultMessageFromCode($result['resultCode']);
@@ -244,13 +250,14 @@ class tx_em_Connection_ExtDirectSoap {
         *
         * @param  $key
         * @param  $user
-        * @return void
+        * @return array
         */
        public function transferExtensionKey($key, $user) {
+               $this->initSoap();
                $params = array(
-                       'modifyExtensionKeyData' => array(
-                                'extensionKey' => $key,
-                                'ownerUsername' => $user
+                       'modifyExtensionKeyData' => array(
+                               'extensionKey' => $key,
+                               'ownerUsername' => $user
                        )
                );
                $result = $this->soapCall('modifyExtensionKey', $params);
@@ -294,7 +301,6 @@ class tx_em_Connection_ExtDirectSoap {
                                'password' => $password
                        )
                );
-               $this->initSoap();
        }
 
        /**
@@ -303,24 +309,25 @@ class tx_em_Connection_ExtDirectSoap {
         * @return void
         */
        protected function initSoap() {
-               if ($this->repository->getWsdlUrl()) {
-                       /** @var $soap tx_em_Connection_Soap */
-                       $this->soap = t3lib_div::makeInstance('tx_em_Connection_Soap');
-                       $this->soap->init(
-                               array(
-                                       'wsdl' => $this->repository->getWsdlUrl(),
-                                       //'authentication' => 'headers',
-                                       'soapoptions' =>
+               if(!is_object($this->soap) || !($this->soap instanceof tx_em_Connection_Soap)) {
+                       if ($this->repository->getWsdlUrl()) {
+                                       /** @var $soap tx_em_Connection_Soap */
+                               $this->soap = t3lib_div::makeInstance('tx_em_Connection_Soap');
+                               $this->soap->init(
                                        array(
-                                               'trace' => 1,
-                                               'exceptions' => 1
-                                       )
-                               ),
-                               $this->settings['fe_u'],
-                               $this->settings['fe_p']
-                       );
+                                               'wsdl' => $this->repository->getWsdlUrl(),
+                                               'soapoptions' => array(
+                                                       'trace' => 1,
+                                                       'exceptions' => 1
+                                               )
+                                       ),
+                                       $this->settings['fe_u'],
+                                       $this->settings['fe_p']
+                               );
+                       }
                }
        }
+
        /**
         * @param  $data
         * @return bool|NULL|string|tx_em_Settings|unknown