开发者

Kohana 3 routes - empty regular expression

Up until recently I have had a routehandler controller through which all requests pass. This is so that I can direct certain items to certain pages based on entries in a catalogue. However for some reason it has recently stopped working and gives me the following error:

ErrorException [ Warning ]: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Empty regular expression

This comes from the matches() function in the route.php file.

Up until that class is called I have noticed that the $uri variable does contain a string, however once in that function it turns to NULL which throughs the error.

            // Routes for product items
            foreach($items as $item)
            {
                Route::set($item->seoUrl, $item->seoUrl)
                ->defaults(array(
                    'controller' => 'item',
                    'action' => 'index',
                    'id' => $item->id,
                ));
            }

            // Error
            Route::set('error', 'error(/<action>(/<id>))', array('id' => '.+'))
            ->defaults(array(
                    'controller'    => 'error',
                    'action'    => '404',
                    'id'            => FALSE,
            ));

            // Standard - normal Kohana behaviour
            Route::set('standard', '(<controller>(/<action>(/<id>)))')
                ->defaults(array(
                    'controller' => 'catalogue',
                    'action'     => 'index',
            ));

            // RouteHandler Reset - otherwise continuous loop
            Route::set('routeHandler', '£€%')
                ->defaults(array(
                    'controller' => 'routeHandler',
                    'action'     => 'index',
            ));

            $uri = $this->request->param('uri');

            $request = new Request($uri);

            echo $request->execute()
                    ->send_headers()
                    ->response;

The routes for product items still works. Which leads me to believe its the standard route which is causing upset. The reset route has to be there otherwise I get a constant loop through the ro开发者_C百科uteHandler.

Strange thing is this did all work, and nothing has changed in this script to my knowledge.

Any ideas though would be greatly appreciated.


Solved it.

One of the items had an seoUrl of "" NULL basically, so by having this as a route it was confusing all the following routes set in this controller.

Have added a check now to make sure that the $item->seoURL is not empty.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜