[BUGFIX] StorageRepository should ignore not found driver class
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Resource / StorageRepository.php
index d29198d..9a4eff8 100644 (file)
@@ -51,6 +51,19 @@ class StorageRepository extends \TYPO3\CMS\Core\Resource\AbstractRepository {
         */
        protected $typeField = 'type';
 
         */
        protected $typeField = 'type';
 
+       /**
+        * @var \TYPO3\CMS\Core\Log\Logger
+        */
+       protected $logger;
+
+       public function __construct() {
+               parent::__construct();
+
+               /** @var $logManager \TYPO3\CMS\Core\Log\LogManager */
+               $logManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager');
+               $this->logger = $logManager->getLogger(__CLASS__);
+       }
+
        /**
         * Finds storages by type.
         *
        /**
         * Finds storages by type.
         *
@@ -58,6 +71,8 @@ class StorageRepository extends \TYPO3\CMS\Core\Resource\AbstractRepository {
         * @return \TYPO3\CMS\Core\Resource\ResourceStorage[]
         */
        public function findByStorageType($storageType) {
         * @return \TYPO3\CMS\Core\Resource\ResourceStorage[]
         */
        public function findByStorageType($storageType) {
+               /** @var $driverRegistry \TYPO3\CMS\Core\Resource\Driver\DriverRegistry */
+               $driverRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Resource\Driver\DriverRegistry');
                $storageObjects = array();
                $whereClause = $this->typeField . ' = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($storageType, $this->table);
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
                $storageObjects = array();
                $whereClause = $this->typeField . ' = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($storageType, $this->table);
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
@@ -66,7 +81,14 @@ class StorageRepository extends \TYPO3\CMS\Core\Resource\AbstractRepository {
                        $whereClause . $this->getWhereClauseForEnabledFields()
                );
                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                        $whereClause . $this->getWhereClauseForEnabledFields()
                );
                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                       $storageObjects[] = $this->createDomainObject($row);
+                       if ($driverRegistry->driverExists($row['driver'])) {
+                               $storageObjects[] = $this->createDomainObject($row);
+                       } else {
+                               $this->logger->warning(
+                                       sprintf('Could not instantiate storage "%s" because of missing driver.', array($row['name'])),
+                                       $row
+                               );
+                       }
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($res);
                return $storageObjects;
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($res);
                return $storageObjects;
@@ -101,8 +123,19 @@ class StorageRepository extends \TYPO3\CMS\Core\Resource\AbstractRepository {
                        $this->table,
                        ($whereClause ? $whereClause : '1=1') . $this->getWhereClauseForEnabledFields()
                );
                        $this->table,
                        ($whereClause ? $whereClause : '1=1') . $this->getWhereClauseForEnabledFields()
                );
+
+               /** @var $driverRegistry \TYPO3\CMS\Core\Resource\Driver\DriverRegistry */
+               $driverRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Resource\Driver\DriverRegistry');
+
                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                       $storageObjects[] = $this->createDomainObject($row);
+                       if ($driverRegistry->driverExists($row['driver'])) {
+                               $storageObjects[] = $this->createDomainObject($row);
+                       } else {
+                               $this->logger->warning(
+                                       sprintf('Could not instantiate storage "%s" because of missing driver.', array($row['name'])),
+                                       $row
+                               );
+                       }
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($res);
                return $storageObjects;
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($res);
                return $storageObjects;