diff -ru typo3_src.orig/t3lib/class.t3lib_stdgraphic.php typo3_src.new/t3lib/class.t3lib_stdgraphic.php --- typo3_src.orig/t3lib/class.t3lib_stdgraphic.php 2010-09-01 19:48:42.000000000 +0200 +++ typo3_src.new/t3lib/class.t3lib_stdgraphic.php 2010-09-30 16:23:48.000000000 +0200 @@ -2433,14 +2433,23 @@ */ function cacheImageDimensions($identifyResult) { global $TYPO3_DB; - // Create a md5 hash of the filename - $md5Hash = md5_file($identifyResult[3]); - if ($md5Hash) { + $md5Hash = ''; + if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['checkFileHash'] != -1) { + // Create a md5 hash of the file + $md5Hash = md5_file($identifyResult[3]); + } + + $filesize = filesize($identifyResult[3]); + $filemtime = filemtime($identifyResult[3]); + + if ($md5Hash !== FALSE && $filesize !== FALSE && $filemtime !== FALSE) { $fieldArr = array ( 'md5hash' => $md5Hash, 'md5filename' => md5($identifyResult[3]), 'tstamp' => $GLOBALS['EXEC_TIME'], 'filename' => $identifyResult[3], + 'filemtime' => $filemtime, + 'filesize' => $filesize, 'imagewidth' => $identifyResult[0], 'imageheight' => $identifyResult[1], ); @@ -2462,15 +2471,47 @@ function getCachedImageDimensions($imageFile) { global $TYPO3_DB; // Create a md5 hash of the filename - $md5Hash = md5_file($imageFile); - preg_match('/([^\.]*)$/',$imageFile,$reg); - $res = $TYPO3_DB->exec_SELECTquery ('md5hash, imagewidth, imageheight', 'cache_imagesizes', 'md5filename='.$TYPO3_DB->fullQuoteStr(md5($imageFile),'cache_imagesizes')); + $res = $TYPO3_DB->exec_SELECTquery ('md5hash, imagewidth, imageheight, filemtime, filesize', 'cache_imagesizes', 'md5filename='.$TYPO3_DB->fullQuoteStr(md5($imageFile),'cache_imagesizes')); if ($res) { if ($row = $TYPO3_DB->sql_fetch_assoc($res)) { - if ($row['md5hash']!=$md5Hash) { + $fileHasChanged = false; + if ($row['filesize'] && $row['filesize'] != filesize($imageFile)) { + // filesize changed -> content changed, too + $fileHasChanged = true; + } else if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['checkFileHash'] == 1) { + // old behavior - check if content changed + $fileHasChanged = $row['md5hash'] != md5_file($imageFile); + } else { + // smart behavior - avoid md5_file + $filemtime = filemtime($imageFile); + if ($row['filemtime'] != $filemtime) { + // filemtime changed - content might be changed, too + if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['checkFileHash'] == -1) { + // dislike md5_file - force new image + $fileHasChanged = true; + } else { + // check if content has changed with md5_file + if ($row['md5hash'] != md5_file($imageFile)) { + $fileHasChanged = true; + } else { + // content didn't change - update mtime + $fields = array( + 'tstamp' => $GLOBALS['EXEC_TIME'], + 'filemtime' => $filemtime, + ); + if (!$row['filesize']) { + $fields['filesize'] = filesize($imageFile); + } + $TYPO3_DB->exec_UPDATEquery ('cache_imagesizes', 'md5hash='.$TYPO3_DB->fullQuoteStr($row['md5hash'],'cache_imagesizes'), $fields); + } + } + } + } + if ($fileHasChanged) { // file has changed, delete the row $TYPO3_DB->exec_DELETEquery ('cache_imagesizes', 'md5hash='.$TYPO3_DB->fullQuoteStr($row['md5hash'],'cache_imagesizes')); } else { + preg_match('/([^\.]*)$/',$imageFile,$reg); return (array((int) $row['imagewidth'], (int) $row['imageheight'], strtolower($reg[0]), $imageFile)); } } diff -ru typo3_src.orig/t3lib/config_default.php typo3_src.new/t3lib/config_default.php --- typo3_src.orig/t3lib/config_default.php 2010-09-01 19:48:43.000000000 +0200 +++ typo3_src.new/t3lib/config_default.php 2010-09-30 16:25:07.000000000 +0200 @@ -55,6 +55,7 @@ 'TTFLocaleConv' => '', // String: Enter locale conversion string used to recode input to TrueType functions. Eg. 'cp1250..UTF-8'. Deprecated from ver. 3.6.0 of TYPO3. Set up [BE][forceCharset] as strings are automatically converted from database charset to UTF-8. 'TTFdpi' => 72, // Integer: Enter how many dpi the FreeType module uses. Freetype1 should be set to 72. Freetype2 should be set to 96 (otherwise fonts are rendered way bigger than FreeType1). This works as a global scaling factor for Freetype. 'png_truecolor' => FALSE, // Boolean: If set PNGs will get created as truecolor PNGs. If you use GDlib2 you can create truecolor images if they look not well currently. Note that this results in an increased image size. JPEGs get always created in truecolor now (GDlib2 required) + 'checkFileHash' => 1, // Integer. -1,0,1 0=check md5_file if mtimes differ 1=always check md5_file (old behavior) -1=never use md5_file ), 'SYS' => array( // System related concerning both frontend and backend. 'sitename' => 'TYPO3', // Name of the base-site. This title shows up in the root of the tree structure if you're an 'admin' backend user. diff -ru typo3_src.orig/t3lib/stddb/tables.sql typo3_src.new/t3lib/stddb/tables.sql --- typo3_src.orig/t3lib/stddb/tables.sql 2010-09-01 19:48:43.000000000 +0200 +++ typo3_src.new/t3lib/stddb/tables.sql 2010-09-30 13:49:23.000000000 +0200 @@ -168,6 +168,8 @@ md5filename varchar(32) DEFAULT '' NOT NULL, tstamp int(11) DEFAULT '0' NOT NULL, filename varchar(255) DEFAULT '' NOT NULL, + filemtime int(11) DEFAULT '0' NOT NULL, + filesize int(11) DEFAULT '0' NOT NULL, imagewidth mediumint(11) unsigned DEFAULT '0' NOT NULL, imageheight mediumint(11) unsigned DEFAULT '0' NOT NULL, PRIMARY KEY (md5filename) diff -ru typo3_src.orig/typo3/sysext/cms/ext_tables.sql typo3_src.new/typo3/sysext/cms/ext_tables.sql --- typo3_src.orig/typo3/sysext/cms/ext_tables.sql 2010-09-01 19:48:45.000000000 +0200 +++ typo3_src.new/typo3/sysext/cms/ext_tables.sql 2010-09-30 13:49:17.000000000 +0200 @@ -122,6 +122,8 @@ md5filename varchar(32) DEFAULT '' NOT NULL, tstamp int(11) DEFAULT '0' NOT NULL, filename varchar(255) DEFAULT '' NOT NULL, + filemtime int(11) DEFAULT '0' NOT NULL, + filesize int(11) DEFAULT '0' NOT NULL, imagewidth mediumint(11) unsigned DEFAULT '0' NOT NULL, imageheight mediumint(11) unsigned DEFAULT '0' NOT NULL, PRIMARY KEY (md5filename)