Development

#3397 (sfConsoleRequest unusable (affects predefined "cli" env))

You must first sign up to be able to contribute.

Ticket #3397 (closed defect: fixed)

Opened 7 months ago

Last modified 7 months ago

sfConsoleRequest unusable (affects predefined "cli" env)

Reported by: aferber Assigned to: fabien
Priority: major Milestone: 1.1.0 RC2
Component: configuration Version: 1.1.0 DEV
Keywords: Cc:
Qualification: Design decision

Description

Hi,

When trying to use sfConsoleRequest as the request class in any environment, symfony aborts during startup with an exception ("Call to undefined method sfConsoleRequest::getMethodName").

This happens because sfFactoryConfigHandler generates some code (when handling the "response" factory) that tries to call the getMethodName method on the request object, however this method is only defined in sfWebRequest. This makes any request class that doesn't inherit from sfWebRequest (and doesn't provide its own getMethodName method) unusable as the request class.

Proposed solution: make the offending code generated by sfFactoryConfigHandler conditional on the request object actually providing the getMethodName method. Since it is only used to automatically call "$response->setHeaderOnly(true)" on HTTP "HEAD" requests, which only makes sense with web requests anyway, this should not affect any existing code.

Andreas

PS: What really surprises me is that nobody seems to have noticed this before. AFAICT, the problem actually exists for quite some time now. Looks like nobody is really using the CLI environment, or sfConsoleRequest for that matter...

Attachments

symfony-1.1.0-DEV-factory-config-fix.patch (1.0 kB) - added by aferber on 04/23/08 19:12:37.
patch that fixes the problem

Change History

04/23/08 19:12:37 changed by aferber

  • attachment symfony-1.1.0-DEV-factory-config-fix.patch added.

patch that fixes the problem

05/21/08 14:30:21 changed by FabianLange

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

(In [9145]) fix for non web environments. sfFactoryConfigHandler called getMethod and setHeaderOnly also on non web objects causing in fatal errors. fixes #3397

05/21/08 14:32:34 changed by FabianLange

  • qualification changed from Unreviewed to Design decision.
  • milestone set to 1.1.0 RC2.

actually it only works when the request is an sfWebRequest (or extension) and the response is an sfWebResponse (or extension) Instead of your method_exists proposal I implemented an OO instanceof test.

@fabien: I added a TODO there because I really think that this is a bit inelegant.