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

Michiel Roos michiel at netcreators.com
Mon Feb 11 20:57:01 CET 2008


+1

;-)

Met vriendelijke groet,

Michiel Roos

Netcreators BV :: creation and innovation
www.netcreators.com

Interesse in werken bij Netcreators?
http://www.netcreators.com/bedrijf/vacatures/

On Feb 8, 2008, at 2:40 PM, Peter Kuehn [wmdb] wrote:

> This is a svn patch request.
>
> Type: bugfix
>
> Description:
> When $whereClauses is string, preg_replace in lib/ 
> class.tx_dam_db.php on line 454 fails
>
>
> Solution (as described by michiel in a bugnote):
> The comment of the function getReferencedFiles says:
> * @param string $whereClause Extra where clause prepended with " AND "
>
> So the function expects a where clause already prepended with "AND "  
> passed in as a parameter. But then the code round line 496 appends  
> an AND to an imploded where array build out of a lot of were stuf  
> stuffed into the where array
>
> The non workign code reads:
> preg_replace('^AND ', trim($whereClauses))
>
> I suspect that the code should read:
> 'Strip off the AND if it is passed in on a whereClauses sting.'
>
> So that would be:
> preg_replace('/^AND /', '', trim($whereClauses));
>
>
> Notes:
> - the suspect preg_replace-construct exists two times in the class  
> so i fixed both
> - im no king with regexes - just trusting michiel because
> - i couldnt find a single place, where its used with an incoming  
> string so
> - change is basically untested
>
> Bugtracker reference: http://bugs.typo3.org/view.php?id=6766
> Index: class.tx_dam_db.php
> ===================================================================
> --- class.tx_dam_db.php	(revision 8208)
> +++ class.tx_dam_db.php	(working copy)
> @@ -163,7 +163,7 @@
> 	 * @return	array		WHERE clauses as array
> 	 */
> 	 function fillWhereClauseArray($whereClauses=array()) {
> -		$whereClauses = is_array($whereClauses) ? $whereClauses :  
> array('where' => (preg_replace('^AND ', trim($whereClauses))));
> +		$whereClauses = is_array($whereClauses) ? $whereClauses :  
> array('where' => (preg_replace('/^AND /', '', trim($whereClauses))));
>
> 		$where = array();
> 		if (!isset($whereClauses['deleted']) AND ! 
> isset($whereClauses['enableFields'])) {
> @@ -737,7 +737,7 @@
> 	 */
> 	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))));
> +		$whereClauses = is_array($whereClauses) ? $whereClauses :  
> array('where' => (preg_replace('/^AND /', '', trim($whereClauses))));
>
> 		$MM_table = $MM_table ? $MM_table : 'tx_dam_mm_ref';
>
> _______________________________________________
> TYPO3-team-dam mailing list
> TYPO3-team-dam at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-team-dam



More information about the TYPO3-team-dam mailing list