Zend Framework

Zend_Application_Resource_Modules does not correctly compute Bootstrap classname

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.8.0
  • Fix Version/s: 1.8.1
  • Component/s: Zend_Application
  • Labels:
    None

Description

When Zend_Application_Resource_Modules works to use a module with a dash in it, it does not work correctly. When it comes across a module name (and directory name) of item-type, it tries to look for a class called "item-type_Bootstrap".

This does not agree with how things are done in Zend_Controller_Dispatcher_Abstract->_formatName();

A simple fix would be to replace the line:

$bootstrapClass = ucfirst($module) . '_Bootstrap';

in Zend_Application_Resource_Modules with:

$segment = str_replace(array('-', '.'), ' ', strtolower($module));
$segment = preg_replace('/[^a-z0-9 ]/', '', $segment);
$module = str_replace(' ', '', ucwords($segment));
$bootstrapClass = ucfirst($module) . '_Bootstrap';

Activity

Hide
Matthew Weier O'Phinney added a comment -

Fixed in trunk and 1.8 release branch.

Show
Matthew Weier O'Phinney added a comment - Fixed in trunk and 1.8 release branch.
Hide
-.- added a comment -

Line 111 in this fix is unnessesary.

$name = ucwords($name);
Show
-.- added a comment - Line 111 in this fix is unnessesary.
$name = ucwords($name);
Hide
Matthew Weier O'Phinney added a comment -

Um, yes, that line is necessary – that's precisely the functionality implemented in the dispatcher's getModuleName() method (via _formatName()). It allows the ability to translate foo-bar to FooBar – without ucwords(), it would be simply Foobar – which is incorrect.

Show
Matthew Weier O'Phinney added a comment - Um, yes, that line is necessary – that's precisely the functionality implemented in the dispatcher's getModuleName() method (via _formatName()). It allows the ability to translate foo-bar to FooBar – without ucwords(), it would be simply Foobar – which is incorrect.
Hide
Jorge Padron added a comment -

Yes, the function ucwords() is necessary, but it's used twice: lines 111-112

Show
Jorge Padron added a comment - Yes, the function ucwords() is necessary, but it's used twice: lines 111-112
Hide
Matthew Weier O'Phinney added a comment -

OOps! Thanks – I've updated the code now to remove the extraneous call.

Show
Matthew Weier O'Phinney added a comment - OOps! Thanks – I've updated the code now to remove the extraneous call.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: