2011-05-23 39 views
0

直到最近,我都有一个路由处理器控制器,所有的请求都通过它。这样我可以根据目录中的条目将某些项目定向到某些页面。但是由于某种原因,它最近停止工作,并给了我以下错误:Kohana 3路由 - 空的正则表达式

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

这来自于比赛()函数在route.php文件。

直到这个类被调用我已经注意到,$ uri变量确实包含一个字符串,但是一旦在该函数中它将变为NULL,通过该错误。

  // 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; 

产品项目的路线仍然有效。这导致我相信它引起不安的标准路线。重置路线必须在那里,否则我通过routeHandler得到一个常量循环。

奇怪的是,这是所有的工作,并没有什么改变在这个剧本据我所知。

任何想法,但将不胜感激。

回答

0

解决了它。

其中的一个项目基本上都是“NULL”,所以通过将此设置为一个路由,它会混淆在此控制器中设置的所有以下路由。

已经添加了一个检查,以确保$ item-> seoURL不为空。