[BUGFIX] StorageRepository fails to load storages
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Resource / StorageRepository.php
index 98e61c1..eed5977 100644 (file)
@@ -116,13 +116,16 @@ class StorageRepository extends AbstractRepository {
 
                        if (static::$storageRowCache === array()) {
                                $storageObjectsExists = $this->db->exec_SELECTgetSingleRow('uid', $this->table, '');
-                               if ($storageObjectsExists !==  NULL) {
+                               if ($storageObjectsExists !== NULL) {
                                        if ($this->createLocalStorage(
                                                'fileadmin/ (auto-created)',
                                                $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'],
                                                'relative',
-                                               'This is the local fileadmin/ directory. This storage mount has been created automatically by TYPO3.'
+                                               'This is the local fileadmin/ directory. This storage mount has been created automatically by TYPO3.',
+                                               TRUE
                                        ) > 0 ) {
+                                               // reset to null to force reloading of storages
+                                               static::$storageRowCache = NULL;
                                                // call self for initialize Cache
                                                $this->initializeLocalCache();
                                        }
@@ -193,9 +196,10 @@ class StorageRepository extends AbstractRepository {
         * @param string $basePath
         * @param string $pathType
         * @param string $description
+        * @param bool $default set to default storage
         * @return integer uid of the inserted record
         */
-       public function createLocalStorage($name, $basePath, $pathType, $description = '') {
+       public function createLocalStorage($name, $basePath, $pathType, $description = '', $default = FALSE) {
                $caseSensitive = $this->testCaseSensitivity($pathType === 'relative' ? PATH_site . $basePath : $basePath);
                // create the FlexForm for the driver configuration
                $flexFormData = array(
@@ -226,7 +230,8 @@ class StorageRepository extends AbstractRepository {
                        'is_online' => 1,
                        'is_browsable' => 1,
                        'is_public' => 1,
-                       'is_writable' => 1
+                       'is_writable' => 1,
+                       'is_default' => $default ? 1 : 0
                );
                $this->db->exec_INSERTquery('sys_file_storage', $field_values);
                return (int)$this->db->sql_insert_id();
@@ -271,4 +276,4 @@ class StorageRepository extends AbstractRepository {
                return $caseSensitive;
        }
 
-}
\ No newline at end of file
+}