Project

General

Profile

Bug #21269 » class.tx_example_converttask.php

Administrator Admin, 2011-01-17 22:21

 
<?php

class tx_example_convertTask extends tx_scheduler_Task {

public function execute() {

set_time_limit(0);
$offset = 0;
do {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'md5hash, md5filename, filename',
'cache_imagesizes',
'TRUE',
'',
'md5filename',
$offset . ', 10000'
);
if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
// could be either absolute path or relative to site root
$fileName = $row['filename'];
if (strpos($fileName, PATH_site) === false) {
$fileName = PATH_site . $fileName;
}
if (file_exists($fileName)) {
$hash = md5(filemtime($fileName) . filesize($fileName));
if ($row['md5hash'] !== $hash) {
$GLOBALS['TYPO3_DB']->exec_UPDATEquery(
'cache_imagesizes',
'md5filename = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($row['md5filename'], 'cache_imagesizes'),
array(
'md5hash' => $hash,
'tstamp' => $GLOBALS['EXEC_TIME']
)
);
}
}
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
$offset += 10000;

} else {
break;
}
} while (true);
return true;
}
}

?>
(2-2/3)