Bug #33220
closedEmpty content object when select.pidInList=0 set in TS
0%
Description
Hello,
I get an empty return value while rendering dropdown list for countries from the static_info_tables extension. I use following TS:
lib.country = CONTENT lib.country { table = static_countries select { pidInList = 0 orderBy = cn_short_en selectFields = uid,cn_iso_3 } ... }
While tracking the SELECT query in tslib_content, I found out in tslib_content::getQuery() that the logical operator NOT (!) is used to check all select proporties if they exist. This operator does not differ between 0 and empty.
foreach($properties as $property) { ... if(!$conf[$property]) { unset($conf[$property]); } ... }
Even select.pidInList = 0 is set in TS, the condition is fulfilled and $conf['pidInList'] is removed.
In next step, $conf['pidInList'] will be compared with ''
if(!strcmp($conf['pidInList'], '')) { $conf['pidInList'] = 'this'; }
and afterwards 'this' will be replaced with
$GLOBALS['TSFE']->contentPid
This leads to a wrong SQL-query because the ID of current page (4) is taken instead of the pid value (0) set in TS.
SELECT cn_iso_3, cn_short_en FROM static_countries WHERE static_countries.pid IN (4) AND static_countries.deleted=0
In my view, it would be more accurate if to use !isset() instead of NOT in the foreach loop. This will exclude the 0 value in TS.
foreach($properties as $property) { ... - if(!$conf[$property]) { + if(!isset($conf[$property])) { unset($conf[$property]); } ...
Many thanks and best regards,
Alain