0012528: catch credential cache problems during scheduled import
authorCornelius Weiß <c.weiss@metaways.de>
Mon, 14 Nov 2016 15:07:09 +0000 (16:07 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 18 Jan 2017 11:46:08 +0000 (12:46 +0100)
* fix scheduledImport failcount feature (backport from 2015.11-develop)

https://forge.tine20.org/view.php?id=12528

Change-Id: Ie2218f35d7185d2e39a764b55b8cc3b77cd6fa03
Reviewed-on: http://gerrit.tine20.com/customers/4102
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Auth/CredentialCache.php
tine20/Tinebase/Controller/ScheduledImport.php

index 8d283b2..d150ee7 100644 (file)
@@ -289,7 +289,8 @@ class Tinebase_Auth_CredentialCache extends Tinebase_Backend_Sql_Abstract implem
             ? $this->_db->quoteInto($this->_db->quoteIdentifier('valid_until') . ' < ?', Tinebase_DateTime::now()->format(Tinebase_Record_Abstract::ISO8601LONG)) 
             : $this->_db->quoteInto($this->_db->quoteIdentifier('creation_time') . ' < ?', $dateString);
         $where = array($dateWhere);
-             
+
+        // TODO should be handled with looong "valid_until" until time
         if (Tinebase_Application::getInstance()->isInstalled('Felamimail')) {
             // delete only records that are not related to email accounts
             $fmailIds = $this->_getFelamimailCredentialIds();
index a2593b5..e590e45 100644 (file)
@@ -179,22 +179,22 @@ class Tinebase_Controller_ScheduledImport extends Tinebase_Controller_Record_Abs
         $importUser = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $record->user_id, 'Tinebase_Model_FullUser');
         Tinebase_Core::set(Tinebase_Core::USER, $importUser);
 
-        // handle options
-        $options = Zend_Json::decode($record->options);
-        $options['url'] = $record->source;
+        try {
+            // handle options
+            $options = Zend_Json::decode($record->options);
+            $options['url'] = $record->source;
 
-        if (isset($options['cid']) && isset($options['ckey'])) {
-            $credentials = new Tinebase_Model_CredentialCache($options);
-            Tinebase_Auth_CredentialCache::getInstance()->getCachedCredentials($credentials);
+            if (isset($options['cid']) && isset($options['ckey'])) {
+                $credentials = new Tinebase_Model_CredentialCache($options);
+                Tinebase_Auth_CredentialCache::getInstance()->getCachedCredentials($credentials);
 
-            $options['username'] = $credentials->username;
-            $options['password'] = $credentials->password;
-        }
+                $options['username'] = $credentials->username;
+                $options['password'] = $credentials->password;
+            }
 
-        $importer = $record->getOption('plugin');
-        $resource = $record->getOption('importFileByScheduler') ? $this->_getFileToImport($options['url']) : null;
+            $importer = $record->getOption('plugin');
+            $resource = $record->getOption('importFileByScheduler') ? $this->_getFileToImport($options['url']) : null;
 
-        try {
             $importer = new $importer($options);
             $importer->import($resource);
         } catch (Exception $e) {