[TYPO3-core] RFC: #8362: Duplicate entry for [tstamp] and [crdate] in Web->List module for single table in selector-box

Steffen Kamper steffen at sk-typo3.de
Wed May 21 12:27:32 CEST 2008


Hi Ernesto,

your patch looks good, so +1 for your solution.
This makes definitive sense and isn't only the hack, thx for your looking 
into.

vg Steffen

"Ernesto Baschny [cron IT]" <ernst at cron-it.de> schrieb im Newsbeitrag 
news:mailman.1.1211361910.3361.typo3-team-core at lists.netfielders.de...
> Steffen Kamper wrote: on 21.05.2008 10:39:
>
>>>> Solution:
>>>> only add tstamp and crdate if they are not in fields array.
>>>>
>>>> I'm not sure if there is a need to add tstamp and crdate if they are 
>>>> not
>>>> in fields. In this case these fields are not in the table?
>
>>> recordList::makeFieldList() is the method that gets a list of fields. It
>>> adds those tstamp + crdate from TCA if you are an "admin" or if it is 
>>> not
>>> checking for permissions.
>
>> i don't see the check for admin there or any check,
>> the comment says
>> // Add pseudo "control" fields
>
> See file typo3/class.db_list.inc function makeFieldList(), line 700:
>
> // Add special fields:
> if ($dontCheckUser || $BE_USER->isAdmin())      {
> $fieldListArr[]='uid';
> $fieldListArr[]='pid';
> if ($TCA[$table]['ctrl']['tstamp'])
> $fieldListArr[]=$TCA[$table]['ctrl']['tstamp'];
> if ($TCA[$table]['ctrl']['crdate'])
> $fieldListArr[]=$TCA[$table]['ctrl']['crdate'];
> ...
>
> This is the "right way" to add those two fields (as it takes their names
> from the TCA and also checks if they really exist), but you see that it
> is only called if user is "admin" or if the function is called with
> "dontCheckUser", which is not the case when populating the field list.
>
> So the "Add pseudo "control" fields" part that add them again is a bit
> strange. I found out where it came from:
>
> http://code.typo3.org/v4/changeset/1127
>
> This was introduced in 4.0, I guess as a "hack" to get those fields
> selectable by users. Maybe Stucki recalls and can help us out by joining
> this thread.
>
>> So having fields duplicated in list looks obviously wrong and i don't see 
>> a
>> reason why not remove them with the simple patch, we loose nothing. The 
>> bug
>> was posted by an user and this may irretate users.
>
> Yes, I wasn't arguing about the usefulness of the fix, but about the way
> it was solved. The behaviour of adding the fields is of course wrong, as
> those might even not be the correct field names as defined by a table's 
> TCA.
>
> So in my eyes we shouldn't fix the bug caused by a "hack" with another
> "hack", but fix the origin of the problem.
>
> Attached is a diff with how I would solve it. What do you think?
>
> Cheers,
> Ernesto
>


--------------------------------------------------------------------------------


> Index: typo3/class.db_list.inc
> ===================================================================
> --- typo3/class.db_list.inc (Revision 3673)
> +++ typo3/class.db_list.inc (Arbeitskopie)
> @@ -677,9 +677,10 @@
>  *
>  * @param string Table name
>  * @param boolean If set, users access to the field (non-exclude-fields) 
> is NOT checked.
> + * @param boolean If set, also adds crdate and tstamp fields (note: they 
> will also be added if user is admin or dontCheckUser is set)
>  * @return array Array, where values are fieldnames to include in query
>  */
> - function makeFieldList($table,$dontCheckUser=0) {
> + function makeFieldList($table,$dontCheckUser=0,$addDateFields=0) {
>  global $TCA,$BE_USER;
>
>  // Init fieldlist array:
> @@ -697,12 +698,21 @@
>  }
>  }
>
> +
>  // Add special fields:
>  if ($dontCheckUser || $BE_USER->isAdmin()) {
>  $fieldListArr[]='uid';
>  $fieldListArr[]='pid';
> + }
> +
> + // Add date fields
> + if ($dontCheckUser || $BE_USER->isAdmin() || $addDateFields) {
>  if ($TCA[$table]['ctrl']['tstamp']) 
> $fieldListArr[]=$TCA[$table]['ctrl']['tstamp'];
>  if ($TCA[$table]['ctrl']['crdate']) 
> $fieldListArr[]=$TCA[$table]['ctrl']['crdate'];
> + }
> +
> + // Add more special fields:
> + if ($dontCheckUser || $BE_USER->isAdmin()) {
>  if ($TCA[$table]['ctrl']['cruser_id']) 
> $fieldListArr[]=$TCA[$table]['ctrl']['cruser_id'];
>  if ($TCA[$table]['ctrl']['sortby']) 
> $fieldListArr[]=$TCA[$table]['ctrl']['sortby'];
>  if ($TCA[$table]['ctrl']['versioningWS']) {
> Index: typo3/class.db_list_extra.inc
> ===================================================================
> --- typo3/class.db_list_extra.inc (Revision 3673)
> +++ typo3/class.db_list_extra.inc (Arbeitskopie)
> @@ -1292,11 +1292,9 @@
>  $setFields=is_array($this->setFields[$table]) ? $this->setFields[$table] 
> : array();
>
>  // Request fields from table:
> - $fields = $this->makeFieldList($table);
> + $fields = $this->makeFieldList($table, false, true);
>
>  // Add pseudo "control" fields
> - $fields[]='tstamp';
> - $fields[]='crdate';
>  $fields[]='_PATH_';
>  $fields[]='_REF_';
>  $fields[]='_LOCALIZATION_';
> 




More information about the TYPO3-team-core mailing list