Project

General

Profile

Actions

Feature #64158

closed

A faster way to generate GIFBUILDER short MD5 hash inside a filename

Added by Christian Stern almost 10 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Image Generation / GIFBUILDER
Target version:
-
Start date:
2015-01-07
Due date:
% Done:

100%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

It all started with not acceptable filenames during image-generation on a multi language website, after migration to 6.2.. The filename_syntax in 4.5 was: typo3temp/GB/i_{somestrings}_1a37d4a2d0.jpg

This syntax was the same on each language, thus an image is only created once for every language. In 6.2 every image receives a different hash after image_creation. After digging into typo3/sysext/frontend/Classes/Imaging/GifBuilder.php I would like to see one of the following possibilities.

Why I received a different hash per language:

Inside $this->setup there is a huge array (72k lines). This array gets serialized. The hash is generated out of the serialized array. Inside this array sys_langauge_uid exist. Thus the hash is not the same.

Possible Features / Fixes:

  • move the existing hook (gifbuilder-ConfPreProcess) to later moment during image generation and make $this->setup accessible. So I can mess around inside this hook and remove the BBOX from $this->setup.
  • add a new hook to image-processing to access the filename/hash generation (more flexibility on image filename generation could be a nice feature)
  • create the hash out image related configurations only

I did some tests inside GifBuilder.php

I created an array out of image related configs only. This array gets serialzied to build the hash inside an image filename:

$arrayToBeSerilized = array(
    array_keys($this->setup),
    $meaningfulPrefix,
    $this->im,
    $this->w,
    $this->h,
    $this->map,
    $this->workArea,
    $this->combinedTextStrings,
    $this->combinedFileNames,
    $this->data
);

GeneralUtility::shortMD5(serialize($arrayToBeSerilized));

This array will always build different hashes for every image in any constellation, afaik.

I also did some small time measurements during the hash-generation:

Average of hash-generation with $this-setup
~ 0.00049 seconds

Average of hash-generation with image related configs only
~ 0.000019 seconds


Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #91449: Gifbuilder breaks with Security Update (9.5.17); until 9.5.18 performance taskClosed2020-05-20

Actions
Related to TYPO3 Core - Bug #97212: GifBuilder renders wrong image from example typoscript in documentationClosed2022-03-19

Actions
Related to TYPO3 Core - Bug #94648: GifBuilder does not recognize all changes in config when creating HashClosed2021-07-27

Actions
Actions

Also available in: Atom PDF