Development

#8175 (Bypassed filter inputs in admin generator with value = 0)

You must first sign up to be able to contribute.

Ticket #8175 (closed defect: fixed)

Opened 2 months ago

Last modified 1 month ago

Bypassed filter inputs in admin generator with value = 0

Reported by: hugo.hamon Assigned to: Jonathan.Wage
Priority: minor Milestone: 1.4.2
Component: sfDoctrinePlugin Version: 1.4.1
Keywords: admin generator, filters Cc: Kris.Wallsmith
Qualification: Unreviewed

Description

Hi,

I have found a weird behavior in the Doctrine Admin Generator when I use filters in the right sidebar. Consider I have a ShopProduct? model that stores information for my products. A product has a "stock" column to store the current stock. This field is an integer, whose domain is [0 to infinite].

In the generated admin, if I set 30 in the stock filter field, the list is correctly filtered with products whose stock is 30. But, if I try to filter on products, which have a stock at 0, no criteria is added to the query. So the complete products list is displayed.

The problem comes from the sfFormFilterDoctrine class at line 248 in the addNumberQuery() method. In the "elseif" statement, the final condition ( != $valuestext? ) returns a FALSE as the value 0 is considered like an empty string or a FALSE. So, to fix that bug, this statement should be removed or an extra equal symbol must be added : !== $valuestext?.

I have added a patch with my ticket.

Hugo.

Attachments

sfFormFilterDoctrine.patch (0.7 kB) - added by hugo.hamon on 01/25/10 19:18:46.

Change History

01/25/10 19:18:46 changed by hugo.hamon

  • attachment sfFormFilterDoctrine.patch added.

02/02/10 19:43:47 changed by Kris.Wallsmith

  • milestone set to 1.4.2.

02/08/10 19:18:45 changed by Kris.Wallsmith

  • status changed from new to closed.
  • resolution set to fixed.

(In [27748]) [1.3, 1.4] fixed form filtering by 0 on a number column (closes #8175)

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.