Bug #58602

Datepicker issue on multiple datetime fields in BE

Added by Arno Burkhart over 5 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
Start date:
2014-05-07
Due date:
% Done:

100%

TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

After migrating our T3 Websites from 4.5 LTS to 6.2 LTS, we experienced a strange behaviour on the CE access tab for "Publish Dates and Access Rights". The datepicker for field "Expiration Date" applies the selected date in input field for "Publish Date" instead the expected input field for "Expiration Date". After some investigations we found out, that the used input id's are identical:

<input type="text" id="tceforms-datetimefield-536a4b3a16b9a" class="formField tceforms-textfield tceforms-datetimefield hasDefaultValue" name="data[tt_content][2][starttime]_hr" value=""style="width: 163px; " maxlength="20" onchange="typo3form.fieldGet('data[tt_content][2][starttime]','datetime','',1,'0');TBE_EDITOR.fieldChanged('tt_content','2','starttime','data[tt_content][2][starttime]');" />

<input type="text" id="tceforms-datetimefield-536a4b3a16b9a" class="formField tceforms-textfield tceforms-datetimefield upper-1609369200 hasDefaultValue" name="data[tt_content][2][endtime]_hr" value=""style="width: 163px; " maxlength="20" onchange="typo3form.fieldGet('data[tt_content][2][endtime]','datetime','',1,'0');TBE_EDITOR.fieldChanged('tt_content','2','endtime','data[tt_content][2][endtime]');" /><input type="hidden" name="data[tt_content][2][endtime]" value="0" />

Both id's are set to tceforms-datetimefield-536a4b3a16b9a which causes the issue. But this only happens on windows machines. Identical T3 installation moved to a Linux platform is working correct, as the ID's are unique there.

So wie investigated the code, responsible for rendering these fields in typo3\sysext\backend\Classes\Form\FormEngine.php. The referenced id is generated by PHP function uniqid. The referenced line here is 1322:

$inputId = uniqid('tceforms-' . $class . 'field-');

We found 2 ways to fix this issue on a windows machine:

1.) using the optional parameter more_entropy of function string uniqid ([ string $prefix = "" [, bool $more_entropy = false ]] ) and replacing line 1322 with
$inputId = uniqid('tceforms-' . $class . 'field-', true);

2.) a second solution on windows platform is using the PHP parameters session.entropy_file and session.entropy_length.

By each of these approaches, the ID's are getting unique and the datepicker is working as expected.

For getting platform independent, we propose to change the usage of function uniqid() using the optional parameter (true) in TYPO3 core in a future release. This issue also affect TYPO3 6.1.x


Related issues

Related to TYPO3 Core - Bug #59529: Make Functional tests work on fast machines (especially on Windows) Closed 2014-06-12
Related to TYPO3 Core - Bug #59055: Import from .t3d failed on Windows 7 with a lot of messages Closed
Related to TYPO3 Core - Bug #58768: Import from .t3d failed on Windows 7 with a lot of messages (6.1 => 6.2) Rejected 2014-05-13
Related to TYPO3 Core - Bug #59701: uniqid() not returning unique values Closed 2014-06-20
Related to TYPO3 Core - Bug #63943: PHPUnit-Tests fail on Windows Closed 2014-12-16

Associated revisions

Revision fa817a7e (diff)
Added by Tymoteusz Motylewski over 5 years ago

[BUGFIX] Add more entropy to uniqid

uniqid() generates values based on current time,
subsequent calls may return the same value on a fast machine.

On Windows it's even worse, as uniqid()
has single-second-resolution out of the box.

Right now it is used in many places in the core,
also for creating temporary identifiers
for newly created records (in the datahandler).

The solution is to add a second parameter to
all calls (which adds more entropy).
see http://php.net/manual/en/function.uniqid.php

To make code consistent, this change adds the
second parameter to all occurences of uniqid.

Resolves: #59701
Resolves: #58602
Resolves: #59055
Releases: master, 6.2
Change-Id: Id791556d45b4289d75411ff19ae050144fbfe51b
Reviewed-on: http://review.typo3.org/30948
Reviewed-by: Anja Leichsenring <>
Tested-by: Anja Leichsenring <>
Reviewed-by: Wouter Wolters <>
Tested-by: Wouter Wolters <>
Reviewed-by: Stefan Froemken <>
Tested-by: Stefan Froemken <>
Reviewed-by: Markus Klein <>
Tested-by: Markus Klein <>

Revision 5df3d530 (diff)
Added by Tymoteusz Motylewski about 5 years ago

[BUGFIX] Add more entropy to uniqid

uniqid() generates values based on current time,
subsequent calls may return the same value on a fast machine.

On Windows it's even worse, as uniqid()
has single-second-resolution out of the box.

Right now it is used in many places in the core,
also for creating temporary identifiers
for newly created records (in the datahandler).

The solution is to add a second parameter to
all calls (which adds more entropy).
see http://php.net/manual/en/function.uniqid.php

To make code consistent, this change adds the
second parameter to all occurences of uniqid.

Resolves: #59701
Resolves: #58602
Resolves: #59055
Releases: master, 6.2
Change-Id: Id791556d45b4289d75411ff19ae050144fbfe51b
Reviewed-on: http://review.typo3.org/33328
Reviewed-by: Markus Klein <>
Tested-by: Markus Klein <>

History

#1 Updated by Christian Kuhn over 5 years ago

wah ... php madness ...

http://stackoverflow.com/questions/4070110/how-unique-is-uniqid

<quote>
"As others below note, without prefix and without "added entropy", this function simply returns the UNIX timestamp with added microsecond counter as a hex number; it's more or less just microtime(), in hexit form.

[...]

Also worth to note is that since microtime() only works on systems that have gettimeofday() > present, which Windows natively DOES NOT, uniqid() might yield just the single-second-resolution UNIX timestamp in a Windows environment."

"In other words without "more_entropy", the function is absolutely horrible and should never be used,"
</quote>

So, we should review the current usages of uniqid (maybe we leave out tests), to see if we should add the "more_entropy" parameter for cases where two uniqid() are possible during one request ...

#2 Updated by Marc Bastian Heinrichs over 5 years ago

  • Category set to DataHandler aka TCEmain
  • Assignee set to Marc Bastian Heinrichs
  • Priority changed from -- undefined -- to Must have
  • Target version set to next-patchlevel

uniqid is also used in ImportExport for creating the 'NEW' id for new records, so this obviously the reason that breaks impexp on win.

#3 Updated by Marc Bastian Heinrichs over 5 years ago

  • Assignee deleted (Marc Bastian Heinrichs)

#4 Updated by Gerrit Code Review over 5 years ago

  • Status changed from New to Under Review

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/30948

#5 Updated by Gerrit Code Review over 5 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/30948

#6 Updated by Gerrit Code Review over 5 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/30948

#7 Updated by Gerrit Code Review over 5 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/30948

#8 Updated by Gerrit Code Review over 5 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/30948

#9 Updated by Gerrit Code Review over 5 years ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/30948

#10 Updated by Gerrit Code Review over 5 years ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/30948

#11 Updated by Gerrit Code Review over 5 years ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/30948

#12 Updated by Gerrit Code Review over 5 years ago

Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/30948

#13 Updated by Tymoteusz Motylewski over 5 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#14 Updated by Gerrit Code Review over 5 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33328

#15 Updated by Gerrit Code Review about 5 years ago

Patch set 2 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33328

#16 Updated by Tymoteusz Motylewski about 5 years ago

  • Status changed from Under Review to Resolved

#17 Updated by Benni Mack over 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF