contao/test — Issue #2577: CSS Import trying to write file resulting in an uncatched exception
Author: importer
Created: 2011-11-29 09:55:38+00:00
State: open
Labels: backend, Defect, Invalid

Tried to become familiar with CSS importing feature while transferring existing site to Contao. So I had to upload my existing CSS files to tl_files subfolder prior to selecting them in Theme manager for CSS import. The latter however resulted in an uncaught exception:

```
Fatal error: Uncaught exception Exception with message Cannot create file "import-source.css" thrown in /system/libraries/File.php on line 109

#0 /system/modules/backend/StyleSheets.php(160): File->__construct('import-source.css')
#1 /system/modules/backend/StyleSheets.php(80): StyleSheets->writeStyleSheet(Array)
#2 /system/modules/backend/StyleSheets.php(657): StyleSheets->updateStyleSheet(6)
#3 /system/modules/backend/Backend.php(193): StyleSheets->importStyleSheet(Object(DC_Table), 'tl_style_sheet', Array)
#4 /contao/main.php(101): Backend->getBackendModule('themes')
#5 /contao/main.php(304): Main->run()
#6 {main}
```

The mentioned import source file is

```
-rw-r--r-- 1 user apache 7213 Sep 10 09:26 import-source.css
```

First of all I think the related part of code in StyleSheets.php isn't safely using API of class Files and thus making your code less modularized with all implied disadvantages - it's applying _absolute_ pathname in a separate test for file existance, then using _relative_ pathname on using class Files resulting in implication of class File actually working in same base folder.
But regarding one of my previous reports and your (Leo) response on it missing the point it seems to be a failure by design in Contao as a whole. Unfortunately there is no real MVC-separation in Contao.

Regarding this issue, it's due to my usual restrictions on setting up a website: I'm used to reduce write access to files to a minimum. This obviously doesn't include writability for web server to the base of website. Though this is my business, I'd love to have some catched error message instead of an uncaught exception due to failing file write operation. And this is meant from a user's point of view, who is not involved in development or even familiar with PHP code.

--- _Originally created by soletan on September 26th, 2010, at 11:15pm (ID 2577)_