Part of the EllisLab Network

Bug Report

Default controller doesn’t work in presence of ‘catch all’ route.

Date: 10/02/2008 Severity: Minor
Status: Resolved Reporter: Pascal Kriete
Version: 1.7.0 SVN
Keywords: Libraries, Router Class

Description

A recent change in the _set_routing function breaks the default controller when a .* / .+ / :any route is set (a common practice to get nice 404s).

It used to be that the function returned after setting a default controller.  Now it sets the uri string to the default controller and continues.

As a result, the _parse_routes function is called on the default controller uri.  That uri matches the catch-all route and the custom 404 page is displayed.

Basically, if there is no uri string, the default controller should be called without checking for a valid route.

Code Sample

// Called uri: http://example.com/

$route = array(
                
'default_controller'                    => 'main',
                
'scaffolding_trigger'                    => '',
                
                
// Redundancy department of redundancy
//                'main'                                    => 'main',

                // Session routes
                
'login'                                    => 'session/login',
                
'logout'                                => 'session/logout',
                
'register'                                => 'session/register',

                
// Page routes
                
'page/(:num)'                            => 'project/home/$1',
                
'page/create'                            => 'project/create',
                
'page/(:num)/edit'                        => 'page/edit/$1',

                
// Catchall 404
                
'.*'                                    => 'main/error_404'
);

Expected Result

Call main::index()

Actual Result

Calls main::error_404()

Comment on Bug Report

Page 1 of 1 pages
Posted by: Rick Ellis on 2 October 2008 5:03pm
Rick Ellis's avatar

Hm… yeah, that change was to allow default controllers to be specified in subdirectories.  We’ll have to finesse it… thanks.

Posted by: Rick Ellis on 2 October 2008 7:58pm
Rick Ellis's avatar

It should be fixed now in SVN.

Posted by: Pascal Kriete on 2 October 2008 9:10pm
Pascal Kriete's avatar

Phew, talk about a quick fix.

Works like a charm. Thanks.

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?