Project

General

Profile

Bug #46020 » imageDimZeroChecker.patch

Checks for 0 width/height on images and throws exception for getting a stack trace - Markus Klein, 2014-03-31 13:42

View differences:

typo3/sysext/core/Classes/Resource/Index/MetaDataRepository.php
***************************************************************/
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\SingletonInterface;
/**
......
'cruser_id' => TYPO3_MODE == 'BE' ? $GLOBALS['BE_USER']->user['uid'] : 0
);
$emptyRecord = array_merge($emptyRecord, $additionalFields);
$fileObject = ResourceFactory::getInstance()->getFileObject($fileUid);
if (strpos($fileObject->getMimeType(), 'image') === 0 && (empty($updateRow['width']) || empty($updateRow['height']))) {
throw new \ErrorException('Given metadata did not contain valid width/height data for file: ' . $fileObject->getIdentifier());
}
$this->getDatabaseConnection()->exec_INSERTquery($this->tableName, $emptyRecord);
$record = $emptyRecord;
$record['uid'] = $this->getDatabaseConnection()->sql_insert_id();
......
}
$row = $this->findByFileUid($fileUid);
if (count($updateRow) > 0) {
$fileObject = ResourceFactory::getInstance()->getFileObject($fileUid);
if (strpos($fileObject->getMimeType(), 'image') === 0 && (empty($updateRow['width']) || empty($updateRow['height']))) {
throw new \ErrorException('Given metadata did not contain valid width/height data for file: ' . $fileObject->getIdentifier());
}
$updateRow['tstamp'] = time();
$this->getDatabaseConnection()->exec_UPDATEquery($this->tableName, 'uid = ' . (int)$row['uid'], $updateRow);
(7-7/8)