2

Hello i am facing this notice in my web application that powered on Yii 1.14 on a sub domain in godaddy and it crashes my application.

Undefined offset: 0

/home/uname/public_html/some_dir/yii/framework/web/CUrlManager.php(656)

 public function __construct($route,$pattern)
 {
     if(is_array($route))
     {
         foreach(array('urlSuffix', 'caseSensitive', 'defaultParams', 'matchValue', 'verb', 'parsingOnly') as $name)
         {
            if(isset($route[$name]))
                 $this->$name=$route[$name];
        }
         if(isset($route['pattern']))
             $pattern=$route['pattern'];
         $route=$route[0];
     }
     $this->route=trim($route,'/');

     $tr2['/']=$tr['/']='\\/';

     if(strpos($route,'<')!==false && preg_match_all('/<(\w+)>/',$route,$matches2))
     {
         foreach($matches2[1] as $name)
             $this->references[$name]="<$name>";
     }


$this->hasHostInfo=!strncasecmp($pattern,'http://',7) || !strncasecmp($pattern,'https://',8);
MH2K9
  • 11,951
  • 7
  • 32
  • 49

2 Answers2

2

This error occurs if your config is corrupt. Check your config in:

['components']['urlManager']['rules']

If you have set an empty array at this position, you'll get the reported error.

return array(
    'components'    => array(
        'urlManager'   => array(
                'rules' => array(
                    '<controller:\w+>/<id:\d+>'
                        => '<controller>/view', // fine

                    array(), // Won't work!!
                    '<controller:\w+>/<id:\d+>'
                        => array(), // Won't work!!
                ),
        )
    )
)

Please check the documentation and update to the most recent version 1.1.15 which is an important security update.

Fabian Horlacher
  • 1,899
  • 1
  • 24
  • 31
  • Before few minutes i solved the problem, it was empty rule as you mentioned -i have no idea how it got deleted it looks i have a ghost in my host-, thanks a lot sir, unfortunately i can't up vote you because my reputation still low, regards. – Hamza Al Darawsheh Sep 15 '14 at 21:40
0

I had the same error. In my case that was duplicate of code('urlFormat'=>'path',) like this:

'urlManager'=>array(
        'showScriptName'=>false,
        'urlFormat'=>'path',
        'rules'=>array(
        'class'=>'application.components.UrlManager',
        'urlFormat'=>'path', //duplicate
        'showScriptName'=>false,
        'rules'=>array(
            ...
        ),
        ),
    ),

in my 'urlManager' config. I have deleted one of them('urlFormat'=>'path',) and error had gone

user3410311
  • 582
  • 4
  • 6