[TYPO3-core] RFC: #15814: Feature: Add a concatenate class

Helmut Hummel helmut at typo3.org
Sat Sep 25 21:46:40 CEST 2010


Hi,

On 25.09.10 20:34, Steffen Kamper wrote:
> 
> There is no way to concatenate files like javascript or css files / 
> inline blocks.

I' a bit cofused.

t3lib_Compressor already concatenates .css files, but not .js files.

Now you propose t3lib_Concatenate to concatenate .js, .css files (and
any other file types) and "inline" blobs. But can this really work out?

> The attached patch offers this possibility in a very easy way.
> 
> Comments:
> this first patch offers the possibility to concatenate files. The usage 
> patch shows how to use it, it concatenates all javascript of backend.php

The concatenation only works if there are no references to other files
or relative URLs in the JavaScript, right? Can we asure this for all JS
Scripts?

The patch suggests, that concatanation would work for CSS, but it also
won't if there are references to images or other CSS files.

t3lib_Compressor does URL rewriting for CSS but the proposed
t3lib_Concatenate does not. I do not like to have two classes doing
similar things. At least for me it's not clear when to use one over the
other.

Some comments on the code:

* If you do not want use t3lib_div::writeFile(), like Marcus suggested,
you must at least call t3lib_div::fixPermissions() on the created file.
* I do not understand why memory consumption is a problem for
t3lib_Concatenate, but not for t3lib_Compressor (which uses
t3lib_div::writeFile()
* you use uniqid() to create a unique filename, which will create a new
file on each hit, because the filename is random (file_exists will
always fail)
* Why do you use a enumerated array for $this->scripts and store the key
inside the array? Why not $this->scripts[$name] or $this->scripts[$file]?
* Method exists would be obsolete (can be replaced with
array_key_exists()) if you adapt the storage like mentioned above
* registered files must be relative to PATH_Site, which is problematic
if it comes to extensions and the possiblility of different installation
locations
* mimeTypes differ from file extensions. A mimeType is something like
"text/plain" not ".txt" So the variable and method names should be changed

I guess that's all I found ;)

Regards Helmut


More information about the TYPO3-team-core mailing list