[TYPO3-dam-devel] RFC #6766: getReferencedFiles $whereClauses as string

Benjamin Mack benni at typo3.org
Fri May 2 15:55:34 CEST 2008


Hey,

yes, I did a grep, and found only the two in the tx_dam_db file.


Michiel Roos wrote:
> If this patch covers all occurences of this bug then +1
> 
> 
> On May 2, 2008, at 10:43 AM, Benjamin Mack wrote:
> 
>> Hey guys,
>>
>> this is a SVN patch request for the DAM project.
>>
>> Severity: no-brainer
>>
>> Branches: Both trunk and dam_1.0 branch
>>
>> Problem:
>> In two cases in "lib/class.tx_dam_db.php" the use preg_replace is just 
>> simply wrong. It should remove the "AND..." in front of a whereClause. 
>> Then the preg_replace needs to look like preg_replace('/AND /', '', 
>> $whereClauses);.
>> unfortunately, the second parameter is left out.
>>
>> Solution:
>> Add the second (empty '') parameter.
>>
>> Notes:
>> As this is just a clear wrong use of a function call, I'd like to 
>> commit this in 24h if no one objects.
>>
>> -- 
>> greetings,
>> benni.
>> -SDG-
>> Index: lib/class.tx_dam_db.php
>> ===================================================================
>> --- lib/class.tx_dam_db.php    (revision 9050)
>> +++ lib/class.tx_dam_db.php    (working copy)
>> @@ -163,7 +163,9 @@
>>      * @return    array        WHERE clauses as array
>>      */
>>      function fillWhereClauseArray($whereClauses=array()) {
>> -        $whereClauses = is_array($whereClauses) ? $whereClauses : 
>> array('where' => (preg_replace('^AND ', trim($whereClauses))));
>> +        if (!is_array($whereClauses)) {
>> +            $whereClauses = array('where' => preg_replace('/^AND /', 
>> '', trim($whereClauses)));
>> +        }
>>
>>         $where = array();
>>         if (!isset($whereClauses['deleted']) AND 
>> !isset($whereClauses['enableFields'])) {
>> @@ -737,7 +739,9 @@
>>      */
>>     function referencesQuery($local_table, $local_uid, $foreign_table, 
>> $foreign_uid, $MM_ident='', $MM_table='tx_dam_mm_ref', $fields='', 
>> $whereClauses=array(), $groupBy='', $orderBy='', $limit=1000) {
>>
>> -        $whereClauses = is_array($whereClauses) ? $whereClauses : 
>> array('where' => (preg_replace('^AND ', trim($whereClauses))));
>> +        if (!is_array($whereClauses)) {
>> +            $whereClauses = array('where' => preg_replace('/^AND /', 
>> '', trim($whereClauses)));
>> +        }
>>
>>         $MM_table = $MM_table ? $MM_table : 'tx_dam_mm_ref';
>>
>> @@ -1558,4 +1562,4 @@
>>     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dam/lib/class.tx_dam_db.php']); 
>>
>> }
>>
>> -?>
>> \ No newline at end of file
>> +?>
>> Index: lib/class.tx_dam_db.php
>> ===================================================================
>> --- lib/class.tx_dam_db.php    (revision 9058)
>> +++ lib/class.tx_dam_db.php    (working copy)
>> @@ -451,7 +451,9 @@
>>      */
>>     function getReferencedFiles($foreign_table='', $foreign_uid='', 
>> $MM_ident='', $MM_table='tx_dam_mm_ref', $fields='', 
>> $whereClauses=array(), $groupBy='', $orderBy='', $limit=1000) {
>>
>> -        $whereClauses = is_array($whereClauses) ? $whereClauses : 
>> array('where' => (preg_replace('^AND ', trim($whereClauses))));
>> +        if (!is_array($whereClauses)) {
>> +            $whereClauses = array('where' => preg_replace('/^AND /', 
>> '', trim($whereClauses)));
>> +        }
>>
>>         $fields = $fields ? $fields : tx_dam_db::getMetaInfoFieldList();
>>         $local_table = 'tx_dam';
>> _______________________________________________
>> Before posting to this list, please have a look to the posting rules
>> on the following websites:
>>
>> http://typo3.org/teams/core/core-mailinglist-rules/
>> http://typo3.org/development/bug-fixing/diff-and-patch/
>> _______________________________________________
>> TYPO3-team-dam mailing list
>> TYPO3-team-dam at lists.netfielders.de
>> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-team-dam
> 
> 
> Met vriendelijke groet,
> 
> Michiel Roos
> 
> Netcreators BV :: creation and innovation
> www.netcreators.com
> 
> Interesse in werken bij Netcreators?
> http://www.netcreators.com/bedrijf/vacatures/
> 

-- 
greetings,
benni.
-SDG-


More information about the TYPO3-team-dam mailing list