Development

#5090 (sfError404Exception not thrown if sfObjectRoute->getObject fails to return object)

You must first sign up to be able to contribute.

Ticket #5090 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

sfError404Exception not thrown if sfObjectRoute->getObject fails to return object

Reported by: joes Assigned to: Jonathan.Wage
Priority: major Milestone: 1.2.2
Component: routing Version: 1.2.1
Keywords: Cc:
Qualification: Unreviewed

Description

This, I believe, is specific for when the route is of type sfDoctrineRoute.

On row 109 sfObjectRoute checks if the object returned by getObjectForParameters is_null before throwing a sfError404Exception:

109. if (is_null($this->object = $this->getObjectForParameters($this->parameters)) &&  (!isset($this->options['allow_empty']) || !$this->options['allow_empty']))
110. {
111.  throw new sfError404Exception(sprintf('Unable to find the %s object with the following parameters "%s").', $this->options['model'], str_replace("\n", '', var_export($this->filterParameters($this->parameters), true))));
112. }

However, getObjectForParameters in sfDoctrineRoute returns false if it fails to retrieve a object and, thus, the check on row 109 won't function as it takes a null value to signify a failed retrieval.

This is what the check on row 109 should look like if it is to work as expected for sfDoctrineRoute:

109. if (!($this->object = $this->getObjectForParameters($this->parameters)) && (!isset($this->options['allow_empty']) || !$this->options['allow_empty']))

Change History

11/27/08 08:28:52 changed by fabien

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

(In [13382]) [1.2] fixed sfObjectRoute to work with Doctrine when no object is returned (closes #5090, #5091)

12/19/08 00:01:51 changed by jeremy

  • status changed from closed to reopened.
  • version changed from 1.2.0 RC1 to 1.2.1.
  • resolution deleted.
  • milestone changed from 1.2.0 to 1.2.2.

This is still a problem in 1.2. The test still fails, because you're testing against a Doctrine_Collection object.

12/19/08 06:55:35 changed by fabien

  • owner changed from fabien to Jonathan.Wage.
  • status changed from reopened to new.

12/19/08 16:14:27 changed by Jonathan.Wage

  • status changed from new to assigned.

12/19/08 22:46:01 changed by Jonathan.Wage

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

(In [14216]) [1.2] sfDoctrinePlugin: fixes issue where 404 exception is not thrown when no object is found (closes #5090)

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.