Zend routing issue on legacy code

59 views Asked by At

I have an issue with routing on a legacy Zend application I inherited - wondering if someone can help me debug?

So far I've checked:

  • application.config.php - modules are loaded correctly:

    'modules' => array(
    'App',
    'Finding',
    'Listing',
    

and so on

  • module.config.php and the route seems to be ok for the path, for example:

    'listing' => array(
            'type'    => 'segment',
            'options' => array(
                'route'    => '/admin/property/listing[/:action[/:id]][/:component/:optionTitle/:optionValue]',
                'constraints' => array(
                                                                            'action'                 => '[a-z0-9_-]*',
                                                                            'id'                     => '[0-9]+',
                                                                            'component'              => '[a-z0-9_-]*',
                                                                            'optionTitle'    => '[a-z0-9_-]*',
                                                                            'optionValue'   => '[a-z0-9_-]*'
                                                                    ),
    
                'defaults' => array(
                    'controller' => 'Admin\Controller\Listing',
                    'action'     => 'list',
                ),
            ),
        ),
    

The actual error message I get back is:

     The requested URL could not be matched by routing. No Exception available

What I'm doing is in a user logged in area, clicking on a listing category which loads ok, and then submitting a POST form which updates specific attributes in the DB associated with that ID.

However on submit I get the above message, any further ways to track this down, if it's not a route issue?

EDIT

Comments don't really look that good for debug stuff, so I'll add them here, as requested:

Post data array:

   [listingId] => 121 [colvalues] => Array ( [0] => 11 [1] => 22 [2] => 33 [3] => 44 [4] => 55 [5] => 66 [6] => 77 [7] => 88 )

Individual URL structure

    admin/property/listing/view/11111 

It's posting BACK to the same URL - so:

    admin/property/listing/view
1

There are 1 answers

2
AlexP On

The route has an optional id parameter

/admin/property/listing[/:action[/:id]]

You are not posting an id parameter, but rather listingId.

My guess(es) are:

  1. There is no viewAction in Admin\Controller\Listing.

  2. There is controller logic that specifically checks for the id parameter and if not provided returns a response with a 404 status code.

The reason I think these are the causes is because even with the id parameter being missing in your route (admin/property/listing/view) the router should still match the controller action (as id is an optional parameter).