Yii ver. 1.1.14 Problems with googlebot language

Hello, I’m getting a 500 error whenever i try to index the page. The browsers etc work fine, however it gives a 500 error and error on line 46 of the code

class Controller extends CController
    public $layout = '/layouts/site';

    public $domain='';
    public $idCafe;
    public $language='';
    /** @var  Cafe $cafe */
    public $cafe;

     * @var array context menu items. This property will be assigned to {@link CMenu::items}.
    public $menu = [];
     * @var array the breadcrumbs of the current page. The value of this property will
     * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
     * for more details on how to specify this property.
    public $breadcrumbs = array();
    public $keywords = '';
    public $description = '';

    public function beforeAction($action){

        if (!empty(Yii::app()->request->cookies['language']))
        else {
            $systemLangs = Language::codes();
            $selectedLang = $systemLangs[0];

            preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
            if (count($lang_parse[1])) {
                $userLangs = array_combine($lang_parse[1], $lang_parse[4]);
                foreach ($userLangs as $lang => $val) {
                    if ($val === '') $userLangs[$lang] = 1;      
* here it says that the variable $userLangs is undefined
                arsort($userLangs, SORT_NUMERIC);

            foreach ($userLangs as $key => $p) {
                if (in_array($key, $systemLangs)) {
                    $selectedLang = $key;

            Yii::app()->request->cookies['language'] = new CHttpCookie('language', $selectedLang,[


        if (!empty($domain))

        if (!empty($cafe)){
        return true;

    private $_assetsBase;
    public function getAssetsBase()
        if ($this->_assetsBase === null) {
            $this->_assetsBase = Yii::app()->assetManager->publish(
        return $this->_assetsBase;

please help how to solve the problem identifying the language for googlebot? Can i set the default language here or some direct link to open it without error 500?

Quick answer: a couple of lines below your comment, you use $userLangs outside of the block where it was first used/defined.
Edit: No on second look it seems I was wrong.

1 Like

here’s the error i see in the log

2020/02/02 10:55:32 [error] 11892#0: *10696 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined index: HTTP_ACCEPT_LANGUAGE in /var/www/app/components/Controller.php on line 36
PHP message: PHP Notice:  Undefined variable: userLangs in /var/www/app/components/Controller.php on line 45