Project

General

Profile

Actions

Bug #25303

closed

js/iecompatibility.js inclusion triggers compressor bug

Added by Daniel Minder about 13 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
-
Target version:
-
Start date:
2011-03-10
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.5
PHP Version:
5.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

When the linkvalidator modfunc is shown via Web-Info the log is filled with:

Core: Error handler (BE): PHP Warning: filesize(): stat failed for /var/www/conet/htdocs/typo3/atibility.js in /var/www/conet/htdocs/typo3_src-4.5.2/t3lib/class.t3lib_compressor.php line 342

In linkvalidator the BACK_PATH is set correctly. It also adds 3 JS files that are correctly compressed.

The problem lies in the template lib. linkvalidator creates an instance of template and calls setModuleTemplate(). In this method, $this->loadJavascriptLib('js/iecompatibility.js') is called, which calls $this->pageRenderer->addJsFile($this->backPath . $lib);

BUT the backpath is set only in insertHeaderData() which is for FE only!

Can the loadJavascriptLib() call be removed from setModuleTemplate(). According to my debug out iecompatibility.js was already added to the JS list before. If not, is there a way to automatically detect the backPath if the method is called from BE? A third option would be to add a setBackPath() method which has to be called from each BE module that uses the template lib, but this is not so nice...

(issue imported from #M17918)


Related issues 1 (0 open1 closed)

Has duplicate TYPO3 Core - Bug #28255: Warning in log when displaying reportClosed2011-07-16

Actions
Actions #1

Updated by Ingo Pfennigstorf about 13 years ago

  • Target version deleted (0)

This maybe also results in not having a scrollable Viewport. When there are many broken links you can't scroll down or even use any paginator.

In the Error log:
Core: Error handler (BE): PHP Warning: filesize(): stat failed for /var/www/w3s/htdocs/typo3/atibility.js in /data/www/typo3/typo3_src-4.5.2/t3lib/class.t3lib_compressor.php line 341

Actions #2

Updated by Alexander Opitz almost 13 years ago

Can be confirmed with Typo3 4.4.7

Actions #3

Updated by Tomasz Krawczyk almost 13 years ago

I have the same warnings in the php log file and in the BE. My environment is: TYPO3 v 4.5.3, PHP 5.3.6 OS: Windows Server 2003, IIS 6. My warnings occur when functions filesize() and filemtime() are used in class.t3lib_compressor.php line 341. It happens not only with atibility.js file but also with many other js and css files.

The PHP documentation sais that those 2 functions fail when file doesn't exist. So, I made simple test. When I made test.php file executing filesize() and filemtime() with non existing file as a parameter then I saw the same warning. There is no warning if the file exists.

In my xclass in the t3lib_compressor::compressJsFile() and t3lib_compressor::compressCssFile() methods I changed fourth line from:

$unique = $filenameAbsolute . filemtime($filenameAbsolute) . filesize($filenameAbsolute); 

to:

        if( file_exists($filenameAbsolute) )
            $unique = $filenameAbsolute . filemtime($filenameAbsolute) . filesize($filenameAbsolute);
        else
            $unique = $filename . strval( rand(0, 100000) ); 

Now I see no warnings.

I know my solution is ugly. So, please, core developers review my patch.

Actions #4

Updated by Ernesto Baschny almost 13 years ago

  • Status changed from New to Accepted
  • Priority changed from Should have to Must have
  • Target version set to 4.5.4

The problem lies within t3lib_compressor::getFilenameFromMainDir. Then given the $filename = 'js/iecompatibility.js' it will return 'atibility.js' (stripping the first 9 chars from the name), which is then further processed by the other methods.

Changing line 147 from:

$file = PATH_site . $file;

to:

$file = PATH_site . TYPO3_mainDir . $file;

solves this problem, but it has to be proven if this has no side effects, or what it means exactly.

Actions #5

Updated by Daniel Minder almost 13 years ago

Ernesto, I implemented your patch, thought about its implications and tested. Unfortunately, now I get the same warnings as before, but in TemplaVoila:
Core: Error handler (BE): PHP Warning: filesize(): stat failed for /var/www/html/typo3/js/extjs/ux/flashmessages.js in /var/www/html/typo3_src-4.5.3/t3lib/class.t3lib_compressor.php line 341

The header comment of the function says only "Finds the relative path to a file, relative to the TYPO3_mainDir", but it does not say how it expects the input file name! And so, other extension programmers got used to its current behaviour and passed file names relative to PATH_site (e.g. "t3lib/js/extjs/ux/flashmessages.js" for TV).

I looked again why this happens here with linkvalidator and found out that the backPath of the template object is set AFTER calling setModuleTemplate, which results in the error. I've created bug report #28255 for this.

Alexander, Thomas, are you also using linkvalidator and can you relate the log warnings to the display of the linkvalidator report in the backend?

So, I guess the reason for this error is neither the compressor nor the template class as I assumed earlier but lies in the extensions using either the template class or addJsFile of the renderer in a wrong way. Therefore, I vote for a won't fix.

Actions #6

Updated by Chris topher almost 13 years ago

  • Status changed from Accepted to Resolved
  • Target version deleted (4.5.4)

Thanks for digging into this one, guys!

Resolved with #28255.

Actions #7

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF